Select all sheets in workbook

aaronward

Board Regular
Joined
Aug 2, 2006
Messages
165
here is the code i have:

Code:
Sheets(Array("Master", "4001", "4002", "4003", "4004", "4005")).Select

but i dont know how many sheet i will always have or their names, is there any way i have select all sheets in stead of each individual one?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Why do you need to select them?
 
Upvote 0
here is the rest of the code, i am wanting to autofit all sheets, then activate my main sheet:

Code:
Sheets(Array("Master", "4001", "4002", "4003", "4004", "4005")).Select
    Cells.Select
    Cells.EntireColumn.AutoFit
    Sheets(1).Select

but i wont always know how many sheets i have, i may i have 4 or i may have 10...thanks!
 
Upvote 0
Well for a start there's no need to select.

Try this.
Code:
Dim ws As Worksheet
    For Each ws In Worksheets
        ws.Cells.EntireColumn.AutoFit
    Next ws
 
Upvote 0

Forum statistics

Threads
1,217,503
Messages
6,137,020
Members
450,038
Latest member
JackOfBlades

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