Looking to interpret how exactly this works? I love using it, but i really don't know how it works and how i would manipulate it to work in other scenarios?
Set ws3= ThisWorkbook.Worksheets("Sheet3")
Set ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim lastrow, lastrow2, i As Long
Dim Searchfor, j, inarr As Variant
With ws1
lastrow = .Cells(Rows.Count, "G").End(xlUp).Row
inarr = Range(.Cells(3, 1), .Cells(lastrow, 18))
End With
With ws3
lastrow2 = .Cells(Rows.Count, "G").End(xlUp).Row
searcharr = Range(.Cells(3, 7), .Cells(lastrow2, 7))
outarr = Range(.Cells(3, 1), .Cells(lastrow2, 18))
End With
On Error Resume Next
For i = 3 To lastrow2
For j = 3 To lastrow
Searchfor = searcharr(i, 1)
If inarr(j, 1) = Searchfor Then
For kk = 1 To 18
outarr(i, kk - 1) = inarr(j, kk)
Next kk
Exit For
End If
Next j
Next i
With ws1
Range(.Cells(3, 1), .Cells(lastrow2, 18)) = outarr
End With
Set ws3= ThisWorkbook.Worksheets("Sheet3")
Set ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim lastrow, lastrow2, i As Long
Dim Searchfor, j, inarr As Variant
With ws1
lastrow = .Cells(Rows.Count, "G").End(xlUp).Row
inarr = Range(.Cells(3, 1), .Cells(lastrow, 18))
End With
With ws3
lastrow2 = .Cells(Rows.Count, "G").End(xlUp).Row
searcharr = Range(.Cells(3, 7), .Cells(lastrow2, 7))
outarr = Range(.Cells(3, 1), .Cells(lastrow2, 18))
End With
On Error Resume Next
For i = 3 To lastrow2
For j = 3 To lastrow
Searchfor = searcharr(i, 1)
If inarr(j, 1) = Searchfor Then
For kk = 1 To 18
outarr(i, kk - 1) = inarr(j, kk)
Next kk
Exit For
End If
Next j
Next i
With ws1
Range(.Cells(3, 1), .Cells(lastrow2, 18)) = outarr
End With