Macro to copy data from multiple worksheets and paste into a single worksheet (within same workbook)

Kevin Hyskell

New Member
Joined
Feb 7, 2018
Messages
3
I'm working on a workbook to collect several individual worksheets worth of data into two main worksheets. The data is always changing and the amount of populated rows changes as well. What I need:

Delete all rows under row 5 (starting at row 6) in worksheet "Active - TOTAL"
Delete all rows under row 5 (starting at row 6) in worksheet "Complete - TOTAL"

Copy all rows under row 5 (starting at row 6) in worksheet "Active - KH"
Paste into next available row in worksheet "Active - TOTAL"

Copy all rows under row 5 (starting at row 6) in worksheet "Active - BB"
Paste into next available row in worksheet "Active - TOTAL"

Copy all rows under row 5 (starting at row 6) in worksheet "Complete - KH"
Paste into next available row in worksheet "Complete - TOTAL"

Copy all rows under row 5 (starting at row 6) in worksheet "Complete - BB"
Paste into next available row in worksheet "Complete - TOTAL"

In summary, the idea is to have a main worksheet that collects several other worksheet's data. It's all of the same categories of stuff, but there are several contributors. So, the main sheet needs to be refreshed from time to time. It would be nice (but not required) if at the completion of the copy/paste activities the Active - TOTAL worksheet and Complete - TOTAL worksheets could be sorted. Column B is a date, sorting with the latest dates on bottom. But that's a "nice to have" not a "must have"

Please help me!!!

Thank you in advance!
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try these two loops, and repeat/adapt as required:
Code:
Sub DeleteRows()
    If Worksheets("Active - TOTAL").Cells.CurrentRegion.Rows.Count > 5 Then
        Worksheets("Active - TOTAL").Rows("5:" & Worksheets("Active - TOTAL").Cells.CurrentRegion.Rows.Count).Delete
    End If
End Sub
Sub CopyRows()
    For i = 6 To Worksheets("Active - KH").Cells.CurrentRegion.Rows.Count
        Worksheets("Active - KH").Rows(i).Copy
        Worksheets("Active - TOTAL").Cells(Worksheets("Active - TOTAL").Cells.CurrentRegion.Rows.Count + 1, 1).Select
        Worksheets("Active - TOTAL").Paste
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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