Automatic Macros

D

David Fredrickson

How can I automatically initiate a macro when I switch tabs within a worksheet
 
S

Sheeloo

Right-click the Sheetname and select 'View Code'...
In the VB Editor put your code between

Private Sub Worksheet_Activate()

End Sub

this will be executed everytime the sheet is activated
 
B

Bob Phillips

Private Sub Workbook_SheetActivate(ByVal Sh As Object)

Select Case Sh.Name

Case "Sheet1": 'do something
Case "Sheet2": 'do something else
End Select
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top