macro to select all worksheets

Kade

Active Member
Joined
Jul 20, 2002
Messages
258
Hi

I need code to select all sheets when I activate the worksheet "summary"

If I add extra worksheets I need them to be included in the action, (is this called dynamic?)

I recorded this macro using "select all sheets" from the sheet tab.
Then I pasted it into a "worksheet open" in the code area.
However if I add extra sheets they are not included.

I think I need to change the code on the Sheets line, but do not know what to put 8(

Private Sub Worksheet_Activate()
Sheets(Array("summary", "Labrador", "Poodle", "Malt-terrier")).Select
Sheets("summary").Activate
End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
On 2002-09-24 23:29, Kade wrote:
Hi

I need code to select all sheets when I activate the worksheet "summary"

If I add extra worksheets I need them to be included in the action, (is this called dynamic?)

I recorded this macro using "select all sheets" from the sheet tab.
Then I pasted it into a "worksheet open" in the code area.
However if I add extra sheets they are not included.

I think I need to change the code on the Sheets line, but do not know what to put 8(

Private Sub Worksheet_Activate()
Sheets(Array("summary", "Labrador", "Poodle", "Malt-terrier")).Select
Sheets("summary").Activate
End Sub


Try

<pre/>
Private Sub Worksheet_Activate()

With Application
.EnableEvents = False
Worksheets.Select
.EnableEvents = True
End With

End Sub
</pre>
 

Forum statistics

Threads
1,148,160
Messages
5,745,122
Members
423,927
Latest member
Pra56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top