![]() |
Can a macro be triggered when a cell is selected?
Hi,
I'm trying to have a macro executed when a specific cell in the spreadsheet is selected. Is there a way to do this? What would the code look like? Thanks for your help!! Robert |
Can a macro be triggered when a cell is selected?
You can use the worksheet selection change event to do this. Right click on
the sheet tab and select view code. Paste this macro onto the code sheet and change as required to run specific code or call another macro. PS change the cell reference to whatever is appropriate - currently set to A10. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$10" Then MsgBox "Your macro here" End If End Sub Hope this helps Rowan "Linking to specific cells in pivot table" wrote: Hi, I'm trying to have a macro executed when a specific cell in the spreadsheet is selected. Is there a way to do this? What would the code look like? Thanks for your help!! Robert |
Can a macro be triggered when a cell is selected?
Thanks Rowan!!
"Rowan" wrote: You can use the worksheet selection change event to do this. Right click on the sheet tab and select view code. Paste this macro onto the code sheet and change as required to run specific code or call another macro. PS change the cell reference to whatever is appropriate - currently set to A10. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Address = "$A$10" Then MsgBox "Your macro here" End If End Sub Hope this helps Rowan "Linking to specific cells in pivot table" wrote: Hi, I'm trying to have a macro executed when a specific cell in the spreadsheet is selected. Is there a way to do this? What would the code look like? Thanks for your help!! Robert |
All times are GMT +1. The time now is 11:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com