ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Visual Basic - active macro on cell click (https://www.excelbanter.com/excel-programming/370944-visual-basic-active-macro-cell-click.html)

Brettjg

Visual Basic - active macro on cell click
 
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

mudraker[_401_]

Visual Basic - active macro on cell click
 

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

--
mudrake
-----------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...nfo&userid=247
View this thread: http://www.excelforum.com/showthread.php?threadid=57363


Franz Verga

Visual Basic - active macro on cell click
 
Brettjg wrote:
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




All times are GMT +1. The time now is 05:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com