Hello,
I have a piece of code that does a vlookup. I need to add an if statement to the same. cant seem to get it right.
The if statement is as below and the main code below it. Please help.
,
Thanks in advance.
I have a piece of code that does a vlookup. I need to add an if statement to the same. cant seem to get it right.
The if statement is as below and the main code below it. Please help.
Code:
If Not varResult = "" Then
rng.Value = varResult
End If
Code:
Sub vlookup()
Dim ws As Worksheet
Dim rng As Range
Dim varResult As Variant
Set ws = Worksheets("B1 Movements")
Set rng = ws.Range("M3")
Do
varResult = Application.vlookup(rng.Offset(0, -10).Value, Worksheets("Movement Box").Range("C1:S100"), 17, False)
If Not IsError(varResult) Then
rng.Value = varResult
End If
Set rng = rng.Offset(1)
Loop Until rng.Offset(0, -10).Value = ""
End Sub
Thanks in advance.