Progressing Worksheet

Paul Morris

Board Regular
Joined
Sep 27, 2004
Messages
64
Hi There,

Looking to write a macro to go through each worksheet in a workbook and get data from each, want it to select the first worksheet, get data, select next worksheet, etc till it's gone through each tab.

Any ideas on how to do this?

Cheers,
Paul
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Paul

Can you give some more information?

To loop through all worksheets you can try this.
Code:
Dim wb As Workbook
Dim ws As Worksheet
      
     Set wb = ActiveWorkbook
     
     For Each ws in wb.Worksheets
          ' do something with worksheet ws
     Next ws
 
Upvote 0
Well, you could do something like -

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> foo()
<SPAN style="color:#00007F">Dim</SPAN> WkSh <SPAN style="color:#00007F">As</SPAN> Worksheet
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> WkSh <SPAN style="color:#00007F">In</SPAN> ThisWorkbook.Worksheets
    <SPAN style="color:#007F00">' do your stuff here</SPAN>
    <SPAN style="color:#00007F">If</SPAN> WkSh.Name <> "Summary" <SPAN style="color:#00007F">Then</SPAN>
        <SPAN style="color:#00007F">With</SPAN> WkSh
            .Range("A1:A10").Copy Worksheets("Summary").Cells(Worksheets("Summary").Cells(Rows.Count, 1).End(xlUp).Row + 1, 1)
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">Next</SPAN> WkSh
End <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,203,472
Messages
6,055,610
Members
444,803
Latest member
retrorocket129

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