Hi,
This is making me nuts. I have directions and still can't make this work.
I'm trying to replace this calc: Vlookup(V3,Worksheet!$G$4:$J$10,4,0)
So want to lookup the value in row V of sheet2, the lookup range is on worksheet G4:J10.
If sheet2 column V = worksheet column G, then place worksheet column J in sheet2 column W.
Dim lastrow, lastrow2, i As Long
Dim Searchfor, j, inarr As Variant
'Data Dump Sheet
With Sheets("Sheet2")
lastrow = .Cells(Rows.Count, "G").End(xlUp).Row
inarr = Range(.Cells(3, 22), .Cells(lastrow, 22))
End With
'Values to look up & paste Sheet
With Sheets("Worksheet")
lastrow2 = .Cells(Rows.Count, "G").End(xlUp).Row
' load variant array with sercha variables
searcharr = Range(.Cells(4, 7), .Cells(lastrow2, 10))
' define an output aray
outarr = Range(.Cells(4, 10), .Cells(lastrow, 10))
End With
On Error Resume Next
For i = 1 To lastrow2
For j = 1 To lastrow
Searchfor = searcharr(i, 1)
If inarr(j, 1) = Searchfor Then
For kk = 4 To 4
outarr(i, kk - 1) = inarr(j, kk)
Next kk
Exit For
End If
Next j
Next i
' writeout the output array
With Sheets("Sheet2")
Range(.Cells(3, 23), .Cells(lastrow2, 23)) = outarr
End With
This is making me nuts. I have directions and still can't make this work.
I'm trying to replace this calc: Vlookup(V3,Worksheet!$G$4:$J$10,4,0)
So want to lookup the value in row V of sheet2, the lookup range is on worksheet G4:J10.
If sheet2 column V = worksheet column G, then place worksheet column J in sheet2 column W.
Dim lastrow, lastrow2, i As Long
Dim Searchfor, j, inarr As Variant
'Data Dump Sheet
With Sheets("Sheet2")
lastrow = .Cells(Rows.Count, "G").End(xlUp).Row
inarr = Range(.Cells(3, 22), .Cells(lastrow, 22))
End With
'Values to look up & paste Sheet
With Sheets("Worksheet")
lastrow2 = .Cells(Rows.Count, "G").End(xlUp).Row
' load variant array with sercha variables
searcharr = Range(.Cells(4, 7), .Cells(lastrow2, 10))
' define an output aray
outarr = Range(.Cells(4, 10), .Cells(lastrow, 10))
End With
On Error Resume Next
For i = 1 To lastrow2
For j = 1 To lastrow
Searchfor = searcharr(i, 1)
If inarr(j, 1) = Searchfor Then
For kk = 4 To 4
outarr(i, kk - 1) = inarr(j, kk)
Next kk
Exit For
End If
Next j
Next i
' writeout the output array
With Sheets("Sheet2")
Range(.Cells(3, 23), .Cells(lastrow2, 23)) = outarr
End With