jassybun
Member
Hello - I am trying to combine a formula to a VBA loop, to add a "yes" or "no" to the next column, c.offset(,13)
=IF(D2-(C2+TIMEVALUE(L2)+IF(M2="PM",0.5,0))>1,"Yes","No")
to
=IF(D2-(C2+TIMEVALUE(L2)+IF(M2="PM",0.5,0))>1,"Yes","No")
to
Code:
Sub Lookup()
Dim rng As Range
Dim c As Range
Dim result As String
Set rng = Range("B2:B" & Cells(Rows.Count, 2).End(xlUp).Row)
For Each c In rng.Cells
On Error Resume Next
result = Application.WorksheetFunction.VLookup(c.Value, Workbooks("Lookup.xlsx").Worksheets("Sheet1").Range("A2:B350"), 2, False)
If Err.Number <> 0 Then result = "Not Found"
On Error GoTo 0
c.Offset(, 12).Value = result
result = vbNullString
Next c
End Sub
Last edited by a moderator: