If I use VLookup in a cell, I get a correct result. When I have the vlookup function in a VBA loop, I an error that says the value wasn't found. Any idea what could be going wrong? I know I am defining my range correctly and everything. It also isn't inserting a space or anything to get in the way. I'm at a loss.
The code attachment doesn't seem to be working well:
With Sheets("AIMDeck")
Set rng = .Range(.Cells(4, aimloc), .Cells(totalaim + 3, aimloc))
End With
For x = 2 To Sheets("Data").Range("B2") + 1
curraim = Sheets("Total Vehicle Data").Range("A" & x)
If curraim = "Not Required" Then
GoTo nextx
End If
res = Application.VLookup(curraim, rng, 1, False)
If IsError(res) Then
GoTo nextx
Else
missingaim = missingaim - 1
End If
nextx:
Next
The code attachment doesn't seem to be working well:
With Sheets("AIMDeck")
Set rng = .Range(.Cells(4, aimloc), .Cells(totalaim + 3, aimloc))
End With
For x = 2 To Sheets("Data").Range("B2") + 1
curraim = Sheets("Total Vehicle Data").Range("A" & x)
If curraim = "Not Required" Then
GoTo nextx
End If
res = Application.VLookup(curraim, rng, 1, False)
If IsError(res) Then
GoTo nextx
Else
missingaim = missingaim - 1
End If
nextx:
Next