Hi there,
I have a very large spreadsheet (>500000 rows) and need to consolidate the data between the sheets. Can someone please assist me in creating a macro that would search for a row in 1 sheet that has the exact same values for two columns (in the same row) in another sheet?
I have tried to simplify my spreadsheet and have attached a file that includes only 10 rows of data.
Basically, in the sheet "sche", I need to search columns A and B for a row that exactly matches the values in a row in sheet "act", columns D, and E, respectively. If there is a match, I need to copy the range "C:AO" of the matched row from "sche" and paste into F of "act".
Using some answers I found on Mr.Excel and Yahoo Answers, I have drafted a novice code - but obviously, I cannot get it to run.
I also don't know how to declare my variables.
Values in columns A ("sche") and D ("act") are integers.
However, values in column B ("sche") and E ("act") are dates in the format YYYY-MM-DD.
Sub Consolidate_Data()
Dim i, j, LRSche, LRAct
LRSche = Sheets("sche").Range("A" & Rows.Count).End(xlUp).Row
LRAct = Sheets("act").Range("D" & Rows.Count).End(xlUp).Row
For i = 1 To LRSche
For j = 1 To LRAct
If Sheets("sche").Cells(i, "A").Value = Sheets("act").Cells(j, "D") Then
If Sheets("sche").Cells(i, "B").Value = Sheets("act").Cells(j, "E") Then
Sheets("sche").Cells(i, "C").Resize(, 38).Copy
Sheets("act").Cells(j, "F").Paste
End If
End If
Next i
Next j
End Sub
I appreciate any help I can get and thank you very much in advance!
Bookmarks