Caleeco
Well-known Member
- Joined
- Jan 9, 2016
- Messages
- 980
- Office Version
- 2010
- Platform
- Windows
Hello,
I'm having a code structure issue, so the code below is just representative of the problem.
I have several sheets which I would like to have a SelectionChange Event trigger some code to run. There is one routine that I have that needs to run regardless of which SelectionChange event it triggered, so I created a module with said code in the hopes I could CALL it from each of the Sheet codes.
Worksheet Sheet1 Code
Module Level Sub-Routine i want to call
However, upon triggering the SelectionChange event, i get a Compile Error saying that "Sub or Function not defined".
The only way around this is copying the ColourCell() routine into each of the sheet codes, which doesn't feel like the most efficient solution.
Any help is appreciated.
Cheers
Caleeco
I'm having a code structure issue, so the code below is just representative of the problem.
I have several sheets which I would like to have a SelectionChange Event trigger some code to run. There is one routine that I have that needs to run regardless of which SelectionChange event it triggered, so I created a module with said code in the hopes I could CALL it from each of the Sheet codes.
Worksheet Sheet1 Code
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call ColourCell
End Sub
Module Level Sub-Routine i want to call
Code:
Public Sub ColourCell()
ActiveCell.Interior.Color = vbYellow
End Sub
However, upon triggering the SelectionChange event, i get a Compile Error saying that "Sub or Function not defined".
The only way around this is copying the ColourCell() routine into each of the sheet codes, which doesn't feel like the most efficient solution.
Any help is appreciated.
Cheers
Caleeco