Help with For each Sheet next

cprince

Board Regular
Joined
Jul 4, 2006
Messages
67
Hi All,

I ve got a workbook with 3 sheets.

Sheet 1 is called "Total"
Sheet 2 is called "mary"
Sheet 3 is called "Jane"

I may have more sheets in the future, so I want it to loop until there are no more sheets.

I need to copy the range A1:A200 in Sheet2 and paste in Sheet1 then,

copy the range A1:A200 in Sheet3 and paste in Sheet1 at the bottom of pasted data.

For each sheet .

Can someone help me with some code for this?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi
something like
Code:
Sub test()
Dim ws As Worksheet, LastR As Range
Sheets("Total").Columns("a").ClearContents
For Each ws In WorkSheets
     If ws.Name <> "Total" Then
          With Sheets("Total")
              Set LastR = .Range("a" & Rows.Count).End(xlUp).Offset(1)
              If IsEmpty(.Range("a1")) Then Set LastR = .Range("a1")
          End With
          ws.Range("a1:a200").Copy LastR
     End If
Next
End Sub
 
Upvote 0
try something like this
change to suit you

Code:
Sub test()
Dim i As Integer
Dim dest As Range
For i = 2 To ThisWorkbook.Worksheets.Count
Sheets(i).Activate
' for each sheet row 1 is the same header in all the sheets
Set dest = Sheets(1).Cells(Rows.Count, "a").End(xlUp).Offset(1, 0)
Range(Range("a2"), Range("a2").End(xlDown).End(xlToRight)).Copy dest
Next i
End Sub


venkat
 
Upvote 0

Forum statistics

Threads
1,211,685
Messages
6,103,290
Members
447,853
Latest member
olddutch7

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