Moving dynamic group of rows from multiple worksheets to main worksheet

NIZAMPAR

New Member
Joined
Sep 24, 2014
Messages
3
Hi all!

I am writing a code to help copy a dynamic group of rows (i.e. groups with same starting row and various end rows) from multiple worksheet to a main worksheet titled "Summary". I would like this code to cycle through each of the worksheets (except those titled "Summary") and in each worksheet, search column A for the row containing the last non-blank value, highlight and copy all values in columns A through D from row 8 down to the identified row containing the last non-blank value, then activate the Summary worksheet, search in column A of the Summary worksheet for the row containing the last non-blank value and paste the values in the next blank row.

The code that I am using generates the following error message related to the code row highlighted in yellow:
Code:
Runtime error '1001': The information cannot be pasted because the Copy area and the paste area are not the same size and shape.

The code that I am using is as follows:

Code:
Sub SummarizeSheets()
    Dim ws As Worksheet
    Dim lRow As Long
    Dim pasteSheet As Worksheet
     
    Application.ScreenUpdating = False
     
    For Each ws In Worksheets
        If ws.Name <> "Summary" Then
        
        lRow = Range("A" & Rows.Count).End(xlDown).Row
        ws.Range("A8:D" & lRow).Copy
        
        Set pasteSheet = Worksheets("Summary")
        pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
        End If
        
    Next ws
End Sub

Could someone please help me troubleshoot this error? Any help would be greatly appreciated :)

Nikki
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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