Hi - I'm using this code as a vlookup. Is there a way to alter the code so that i'm only looking up the first 3 digits of the value in Column 6 on Sheet6?
Code:
Dim LastRow, LR1, LR2, LR3, i As LongDim Searchfor, j, inarr As Variant
Set wsRS = Sheet6
Set wsDT = Sheet2
With wsDT
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
inarr = .Range(.Cells(2, 1), .Cells(LastRow, 2))
End With
With wsRS
LR1 = .Cells(Rows.Count, "A").End(xlUp).Row
searcharr = .Range(.Cells(2, 6), .Cells(LR1, 6))
outarr = .Range(.Cells(2, 15), .Cells(LR1, 15))
End With
On Error Resume Next
For i = 1 To LR1
For j = 1 To LastRow
Searchfor = searcharr(i, 1)
If inarr(j, 1) = Searchfor Then
For kk = 2 To 2
outarr(i, kk - 1) = inarr(j, kk)
Next kk
Exit For
End If
Next j
Next i
With wsRS
.Range(.Cells(2, 15), .Cells(LR1, 15)) = outarr
.Range("D7:D31").HorizontalAlignment = xlCenter
End With