Reputation: 59
I have a module with a lot of sub's:
Sub a1
Sub a2
Sub a3
...
Sub a10
And in the worksheet, I have a Event Macro:
Private Sub Worksheet_Change(ByVal Target As Range)
...
End Sub
Sub a1 to a9 makes changes in the worksheet (add columns, change values...)
I wish that the event macro starts to work when a1-a9 it will be done (only for a10). Is this posible?
Upvotes: 0
Views: 56
Reputation: 3823
You could add in logic branching to your event change macro, so that it checks for a certain parameter before it runs. First, make a Global Boolean variable, which either holds True or False - then make your sub A9 switch it to True. For example:
Global Start_Event_Code as Boolean
Sub A9
'Other Code
Start_Event_Code = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Start_Event_Code Then
'Do stuff
End If
End Sub
Then you could make it so that the A10 sub switches it off again:
Sub A9
Start_Event_Code = False
'Other Code
End Sub
Upvotes: 1