Hi,
I am trying to loop to check email addresses in column 1 of sheet4 against those of sheet2 in col 6. If found I need to copy corresponding info from sheet2 to sheet4 and then I am done with that email address from sheet4 and need to attempt the next one from sheet4. If not found continue looping in sheet2 until done with that list then loop through sheet3 col 4 looking for address, same thing if found copy info from sheet 3 and continue with next email address in sheet4, else continue looping through sheet3. So basically each address in sheet4 should be found in either sheet2 or sheet3.
The message at the end is just for debugging purposes and not needed.
I would appreciate any help. Thank you in advance.
Sub CompareRecord()
Dim Sht2LastRow As Long
Dim Sht3LastRow As Long
Dim Sht4LastRow As Long
Dim i As Long
Dim j As Long
Dim k As Long
Sht2LastRow = Sheets("Up to 2007").Cells(65536, 1).End(xlUp).Row
Sht3LastRow = Sheets("2009-2011").Cells(65536, 1).End(xlUp).Row
Sht4LastRow = Sheets("WorkFile").Cells(65536, 1).End(xlUp).Row
For i = 2 To Sht4LastRow
For j = 2 To Sht2LastRow
If Sheets("WorkFile").Cells(j, 1).Value = Sheets("Up to 2007").Cells(i, 6).Value Then
Sheets("WorkFile").Cells(j, 4).Value = Sheets("Up to 2007").Cells(i, 4).Value
Sheets("WorkFile").Cells(j, 5).Value = Sheets("Up to 2007").Cells(i, 5).Value
Sheets("WorkFile").Cells(j, 6).Value = Sheets("WorkFile").Cells(i, 1).Value
Sheets("WorkFile").Cells(j, 9).Value = Sheets("Up to 2007").Cells(i, 8).Value
GoTo Done
End If
Next j
For k = 2 To Sht3LastRow
If Sheets("WorkFile").Cells(j, 1).Value = Sheets("2009-2011").Cells(i, 4).Value Then
Sheets("WorkFile").Cells(j, 4).Value = Sheets("2009-2011").Cells(i, 2).Value
Sheets("WorkFile").Cells(j, 5).Value = Sheets("2009-2011").Cells(i, 3).Value
Sheets("WorkFile").Cells(j, 6).Value = Sheets("WorkFile").Cells(i, 1).Value
Sheets("WorkFile").Cells(j, 8).Value = Sheets("2009-2011").Cells(i, 9).Value
Sheets("WorkFile").Cells(j, 9).Value = Sheets("2009-2011").Cells(i, 10).Value
Sheets("WorkFile").Cells(j, 10).Value = Sheets("2009-2011").Cells(i, 21).Value
Sheets("WorkFile").Cells(j, 11).Value = Sheets("2009-2011").Cells(i, 1).Value
Sheets("WorkFile").Cells(j, 12).Value = Sheets("2009-2011").Cells(i, 33).Value
GoTo Done
End If
Next k
Next i
Done: MsgBox "looping"
End Sub
I am trying to loop to check email addresses in column 1 of sheet4 against those of sheet2 in col 6. If found I need to copy corresponding info from sheet2 to sheet4 and then I am done with that email address from sheet4 and need to attempt the next one from sheet4. If not found continue looping in sheet2 until done with that list then loop through sheet3 col 4 looking for address, same thing if found copy info from sheet 3 and continue with next email address in sheet4, else continue looping through sheet3. So basically each address in sheet4 should be found in either sheet2 or sheet3.
The message at the end is just for debugging purposes and not needed.
I would appreciate any help. Thank you in advance.

Sub CompareRecord()
Dim Sht2LastRow As Long
Dim Sht3LastRow As Long
Dim Sht4LastRow As Long
Dim i As Long
Dim j As Long
Dim k As Long
Sht2LastRow = Sheets("Up to 2007").Cells(65536, 1).End(xlUp).Row
Sht3LastRow = Sheets("2009-2011").Cells(65536, 1).End(xlUp).Row
Sht4LastRow = Sheets("WorkFile").Cells(65536, 1).End(xlUp).Row
For i = 2 To Sht4LastRow
For j = 2 To Sht2LastRow
If Sheets("WorkFile").Cells(j, 1).Value = Sheets("Up to 2007").Cells(i, 6).Value Then
Sheets("WorkFile").Cells(j, 4).Value = Sheets("Up to 2007").Cells(i, 4).Value
Sheets("WorkFile").Cells(j, 5).Value = Sheets("Up to 2007").Cells(i, 5).Value
Sheets("WorkFile").Cells(j, 6).Value = Sheets("WorkFile").Cells(i, 1).Value
Sheets("WorkFile").Cells(j, 9).Value = Sheets("Up to 2007").Cells(i, 8).Value
GoTo Done
End If
Next j
For k = 2 To Sht3LastRow
If Sheets("WorkFile").Cells(j, 1).Value = Sheets("2009-2011").Cells(i, 4).Value Then
Sheets("WorkFile").Cells(j, 4).Value = Sheets("2009-2011").Cells(i, 2).Value
Sheets("WorkFile").Cells(j, 5).Value = Sheets("2009-2011").Cells(i, 3).Value
Sheets("WorkFile").Cells(j, 6).Value = Sheets("WorkFile").Cells(i, 1).Value
Sheets("WorkFile").Cells(j, 8).Value = Sheets("2009-2011").Cells(i, 9).Value
Sheets("WorkFile").Cells(j, 9).Value = Sheets("2009-2011").Cells(i, 10).Value
Sheets("WorkFile").Cells(j, 10).Value = Sheets("2009-2011").Cells(i, 21).Value
Sheets("WorkFile").Cells(j, 11).Value = Sheets("2009-2011").Cells(i, 1).Value
Sheets("WorkFile").Cells(j, 12).Value = Sheets("2009-2011").Cells(i, 33).Value
GoTo Done
End If
Next k
Next i
Done: MsgBox "looping"
End Sub