Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro that runs when a cell is selected
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 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro that runs when a cell is selected
This runs when A1 is selected. Right click the sheet tab and select view
code. Paste the following... Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$1" Then MsgBox "Tada" End If End Sub -- HTH... Jim Thomlinson "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 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro that runs when a cell is selected
Thank you Jim and Dave!
regards Daniel "Dave Peterson" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I need a macro that runs other macros until P5=28 | Excel Discussion (Misc queries) | |||
VLOOKUP anchored cell reference changing when macro runs | Excel Discussion (Misc queries) | |||
One macro runs then it auto runs another macro | Excel Discussion (Misc queries) | |||
Macro that runs in the background | Excel Discussion (Misc queries) | |||
Which Macro Runs...? | Excel Discussion (Misc queries) |