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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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>
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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
Back
Top