Hi,
I have been using this macro for years but it is not working, I am trying to combine two sheets based on Text Field A in both sheets.
What am I missing?
Thanks,
Lorr
I have been using this macro for years but it is not working, I am trying to combine two sheets based on Text Field A in both sheets.
VBA Code:
Sub CopyRange()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Sheets("Sheet2").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim ID As Range
Dim foundID As Range
For Each ID In Sheets("Sheet2").Range("A2:A" & LastRow)
Set foundID = Sheets("Sheet1").Range("A:A").Find(ID, LookIn:=xlValues, LookAt:=xlWhole)
If Not foundID Is Nothing Then
Sheets("Sheet2").Range("B" & ID.Row & ":H" & ID.Row).Copy Sheets("Sheet1").Range("I" & foundID.Row)
End If
Next ID
Application.ScreenUpdating = True
End Sub
What am I missing?
Thanks,
Lorr
Last edited by a moderator: