S
Stu
Is it possible to run a macro when a sheet it clicked on to be viewed?
If so how do I do it?
Thanks
If so how do I do it?
Thanks
Workbook_WindowActivate event inHarald Staff said:Hi Stu
In its simplest form; rightclick the Sheet tab, choose View Code, paste this in:
Private Sub Worksheet_Activate()
Call MyMacro
End Sub
Sub MyMacro()
MsgBox "Yo"
End Sub
It runs when you click the sheet's tab. If you need this code to run when activating one
of several windows then you also need to program the
ThisWorkbook module. Post back if that's relevant and troublesome at the same time.
Stu said:Can you run the macro from a module or do you have to run it from that
sheets code?
Thanks
--
Stu
Workbook_WindowActivate event inHarald Staff said:Hi Stu
In its simplest form; rightclick the Sheet tab, choose View Code, paste this in:
Private Sub Worksheet_Activate()
Call MyMacro
End Sub
Sub MyMacro()
MsgBox "Yo"
End Sub
It runs when you click the sheet's tab. If you need this code to run when activating one
of several windows then you also need to program the
module and call it from anything-----Original Message-----
You can (perhaps even should) put MyMacro on a standard
But events code (like Activate)anywhere. But the activate event must stay where it is.