@offthelip I'm using this code for something else and for the life of me i can't figure out why its not working.
I'm looking up data on sheet16 columns A:D starting in row 8. I'm looking to match sheet16 Column A with Column B of Sheet1. Then put Sheet16 columns C:D in Sheet1 Columns D:E.
Sub Test3()
Dim lastrow, lastrow2, i As Long
Dim Searchfor, j, inarr As Variant
Set ws1 = Sheet1
Set ws16 = Sheet16
'Data Dump Sheet
With ws16
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(.Cells(8, 1), .Cells(lastrow, 4))
End With
'Values to look up & paste Sheet
With ws1
lastrow2 = 31 '.Cells(Rows.Count, "A").End(xlUp).Row
' load variant array with sercha variables
searcharr = Range(.Cells(7, 2), .Cells(lastrow2, 2))
' define an output aray
outarr = Range(.Cells(7, 4), .Cells(lastrow2, 5))
End With
On Error Resume Next
For i = 7 To lastrow2
For j = 8 To lastrow
Searchfor = searcharr(i, 1)
If inarr(j, 1) = Searchfor Then
For kk = 3 To 4
outarr(i, kk - 1) = inarr(j, kk)
Next kk
Exit For
End If
Next j
Next i
' writeout the output array
With ws1
Range(.Cells(7, 4), .Cells(lastrow2, 5)) = outarr
End With
End Sub