Extracting Data out of *Many* worksheets

GeneralShamu

Board Regular
Joined
Jul 6, 2007
Messages
127
I have a file that currently has 37 worksheets. The first worksheet, call it sheet 'A' will tell us how many additional sheets we have (currently 36).

The naming convention on the sheets is not numerical (i.e. 1 2 3 4 ...) but:
A1
B1
C1
...
Z1
A2
B2
...
etc...

Does anyone know how I can create a loop that can cycle through these worksheets? After entering each worksheet I will need to extract specific data from that sheet itself but that's going to be a separate series of nested loops.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Like this?

Code:
Dim Sh As Worksheet
For Each Sh In ActiveWorkbook.Worksheets
'    Do stuff with Sh here
Next Sh

Hmmm...haven't yet tried this but the first question I have is that the first sheet ('A') must be handled entirely differently then the rest.

What would be the exact ordering it would cycle through the sheets in the workbook? Would it be in the order you see at the bottom of the Excel window (i.e. in a new file it'd be "Sheet1" "Sheet2" "Sheet3")?

The actual file names are not alphabetical either...so it would be something like:
A1
S1
O1
N1
D1
J2
 
Upvote 0
The order is the order of the tabs. You can exclude a worksheet like this:

Code:
Dim Sh As Worksheet
For Each Sh In ActiveWorkbook.Worksheets
    If Sh.Name <> "A" Then
'        Do stuff with Sh here
    End If
Next Sh
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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