Loop through all sheets and copy used range to bottom of specific tab



Sub loop_sheets_and_copy_used_range()
Dim WS_Count As Integer
Dim I As Integer

With Worksheets("Main")
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

' Set WS_Count equal to the number of worksheets in the active workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 2 To WS_Count

With Worksheets(I)
.UsedRange.Copy Destination:=Worksheets("Main").Range("A" & lastrow + 1)
End With

With Worksheets("Main")
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With

Next I

End Sub


Contact us for some advice and guidance on how your Excel development could be created and start helping your business straight away. Contact Us

Datanology

Leave a Reply

Your email address will not be published. Required fields are marked *