active cell to run macro

A

Auric__

kalpesh said:
it is possibel that when in sheet1 a1 cell is active to run macro

One way is the Worksheet_SelectionChange event. Place this in the worksheet's
class:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If "$A$1" = ActiveCell.Address Then
'your code here
End If
End Sub

If you want your code to run when A1 is the only thing selected, change
ActiveCell.Address to Target.Address.
 
G

Gord Dibben

Auric has pointed you to a method use a selection chamge event.

There are other event types you could use if you choose

BeforeRightClick

BeforeDoubleClick

Sample code..............................

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
Select Case Target.Address(False, False)
Case "A1"
Cancel = True
MyA1Macro
Case "B1"
Cancel = True
MyB1Macro
Case "C1"
Cancel = True
MyC15Macro
End Select
End Sub


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top