Macro that runs when a cell is selected
You can use a worksheet event:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Me.Range("A1:B3")) Is Nothing Then
Exit Sub
End If
Call MacroNameHere
End Sub
This checks to see if you selected any cell(s) in A1:B3. If you did, then it
calls MacroNameHere.
Rightclick on the worksheet tab that should have this behavior. Select view
code. Paste this code into the code window.
Change the range to check to what you want and change the name of the macro,
too.
Daniel Bonallack wrote:
I have a macro that I want to run when the user selects a cell. Can someone
give me the code that would do this?
Thanks in advance!
Daniel
--
Dave Peterson
|