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
 

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

Back
Top