Copy rows from multiple sheets based on cell value on Summary sheet

Victor Moss

Board Regular
Joined
May 3, 2014
Messages
85
Hi guys,

I'd like to do a data validation across multiple worksheets, so on Sheet1 I have Data Validation listing data on a certain sheet. Because I cannot get the result for Data Validation across multiple sheets, I'm using VBA, the Macro needs to run through all sheets except Sheet1, and check each sheet if the Data Validation value exists in Column I of each sheet, if it does, copy the entire row to Sheet1 from row 3 and so forth until all rows have been copied. My code so far:

Application.ScreenUpdating = False

Dim ws As Worksheet
Dim v As Integer

For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Sheet1" Then
For v = 1 To 1000
If ws.Range("I" & v).Value = Sheets("Sheet1").Range("B1").Value Then
ws.Rows(v & ":" & v).Copy
Sheets("Sheet1").Range("A60000").End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues

End If
Next v
End If
Next ws

My problem is that it isn't looping through all sheets and copying all rows. Is there something I am missing? I also get a run-time 13 error, Type Mismatch on this row:

If ws.Range("I" & v).Value = Sheets("Sheet1").Range("B1").Value Then

If anyone can help please?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,129
Office Version
  1. 2010
Platform
  1. Windows
Hi,​
as looping cell by cell to copy row by row is the slowest way so according to Excel basics you should restart from using a filter …​
 

Forum statistics

Threads
1,136,196
Messages
5,674,372
Members
419,505
Latest member
tismail

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
Top