Visual Basic - active macro on cell click

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This must be really obvious but I cannot find this anywhere in HELP. I want
to set up the worksheet so that if a cell is double clicked by the user then
a particular macro will run automatically
 
Have a look at the Worksheet_BeforeDoubleClick event



Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cance
As Boolean)
Your code here
e.g.
test for target.cell.address
If address = A1
do something
end if

End Su
 
Brettjg said:
This must be really obvious but I cannot find this anywhere in HELP.
I want to set up the worksheet so that if a cell is double clicked by
the user then a particular macro will run automatically


Hi Brettjg,

Right click the sheet tab you want this behaviour, select View Code and copy
& past this code:


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Not Intersect(Target, "A1") Is Nothing Then Call MyMacro
End Sub

change A1 with your target cell or range and MyMacro with the name of your
macro.

--
Hope I helped you.

Thanks in advance for your feedback.

Ciao

Franz Verga from Italy
 
Back
Top