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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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