View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default On going onto a sheet run a macro?

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 Workbook_WindowActivate event in
ThisWorkbook module. Post back if that's relevant and troublesome at the same time.

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Stu" wrote in message ...
Is it possible to run a macro when a sheet it clicked on to be viewed?
If so how do I do it?

Thanks
--
Stu