Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro I would like to run each time I switch to a specific
sheet. How can I set this up? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Assign the code to Worksheet Activate
eg This macro toggles A1 between 0 & 1 each time the sheet is activated Private Sub Worksheet_Activate() If Range("A1").Value = 0 Then Range("A1").Value = 1 Else Range("A1").Value = 0 End If End Sub -- Ian -- wrote in message oups.com... I have a macro I would like to run each time I switch to a specific sheet. How can I set this up? Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
So, to be clear, if I change the name to Worksheet_Activate, this will
run on each activation. If instead, I need to set the worksheet activate event to point to my macro, that is what I need to know how to do. Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you rigth click on the sheet tab and click View Code, this will open VBA
editor. In the left pane, double click on the sheet you want to run the code in then, above the code window select Worksheet in the LH drop-down and Activate in the RH one. This will create the Worksheet_Activate subroutine framework (1st & last lines of my code). This is where your code needs to go. I don't know exactly where your code will be, but it could well be in a module which will be listed in the LH pane. If not you can use EditFind to locate the macro name (search in Current Project). Just cut and paste it. -- Ian -- wrote in message oups.com... So, to be clear, if I change the name to Worksheet_Activate, this will run on each activation. If instead, I need to set the worksheet activate event to point to my macro, that is what I need to know how to do. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sheet activation | Excel Discussion (Misc queries) | |||
Sheet protection error msg - Unrequested sheet activation | Excel Programming | |||
Excel macro activation. | Excel Programming | |||
Excel macro activation. | Excel Programming | |||
Excel macro activation. | Excel Programming |