I'm trying to teach myself some VBA. I have a workbook with 2 worksheets, Sheet1 and Sheet2. I found this code below and modified it to work for me. Gets the value of Sheet1!B1, looks for it in Sheet2!K:K, and sets Sheet1!D1 to the value of a cell in column E (K - 6) of Sheet2.
How can I loop this so it looks at B1:B100 and sets D1:D100?
Sub Looping()
Dim rng1 As Range
Dim strSearch As String
strSearch = Range("B1").Value
Set rng1 = Worksheets("Sheet2").Range("K:K").Find(strSearch, , xlValues, xlWhole)
If Not rng1 Is Nothing Then
Range("D1").Value = rng1.Offset(0, -6)
Else
MsgBox strSearch & " not found"
End If
End Sub
Thanks!
.Offset(0, -6). Please edit your question! - Peter Albert