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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

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