ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run Macro When Select Cell (https://www.excelbanter.com/excel-programming/325695-run-macro-when-select-cell.html)

Andibevan[_2_]

Run Macro When Select Cell
 
Hi All,

I know you can run a macro when a new variable is entered in a cell, but can
you run a macro when a cell is selected?

Ta

Andi



Mike Fogleman

Run Macro When Select Cell
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("J1:J100"), Target) Is Nothing Then
'Call your Macro
Else
End If
End Sub

Change the Intersect Range to whatever cell or range you want as the
trigger.
This code goes in the Worksheet Module, not a general module.

Mike F


"Andibevan" wrote in message
...
Hi All,

I know you can run a macro when a new variable is entered in a cell, but
can
you run a macro when a cell is selected?

Ta

Andi






All times are GMT +1. The time now is 07:24 AM.

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