ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can a macro be triggered when a cell is selected? (https://www.excelbanter.com/excel-programming/334233-can-macro-triggered-when-cell-selected.html)

Linking to specific cells in pivot table

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

Rowan[_2_]

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


Linking to specific cells in pivot table

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