Reputation: 719
Pretty basic question. I'm looking for a sub which will be triggered when the user changes the active worksheet to a certain worksheet (calles worksheet3).
Doing some research in the internet could not help me, unfortunately.
The event sub I am looking for should be very similar to the workbook_open
sub. Obviously it is triggered everytime the workbook opens. So my question: is there a similar event sub which is triggered when I open a certain worksheet? Kind of like worksheet3_open
?
Upvotes: 0
Views: 1407
Reputation: 50034
You can use the Worksheet_Activate()
event in the Worksheet3 code page.
Choose your worksheet by double clicking in the PRoject window:
From the drop down at the top, choose "Worksheet"
From the second drop down just to the right choose "Activate".
You'll have a new subroutine created called Worksheet_Activate()
that will fire every time that tab is activated by the user.
You can then call your subroutine inside of that code so it runs as well.
Upvotes: 2
Reputation: 8531
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
End Sub
or
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
End Sub
Nothing on the net????? :)
Upvotes: 1
Reputation: 957
Place the following code under your workbook:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If Sh.Name = "worksheet3" Then
YourSub
End If
End Sub
Upvotes: 0