Access same Worksheet_SelectionChange from multiple sheets

kpierce

Board Regular
Joined
Jun 21, 2010
Messages
76
Hello:
I have created a workbook with 5 identical sheets. I am utilizing the following functions:
Worksheet_SelectionChange
Worksheet_Change

Instead of having this VBA code in each sheet, is it possible to put this code in a module and then in the sheet, just tell it to run the function in the module. ie, one copy of the VBA code for the entire workbook.

The issue I am having is, when I update the VBA code, I have to replicate it out to each sheet.

Any advice is greatly appreciated.

Thanks
kpierce
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi kpierce,

Looks like you would have to put the code in the "ThisWorkbook" section and use the below Sub types

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

End Sub

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)

End Sub

Difficult to know exactly though without seeing the code...

Hope this helps,
Cheers,
Alan.
 
Upvote 0

Forum statistics

Threads
1,212,141
Messages
6,106,197
Members
448,005
Latest member
Valvictor

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top