Reputation: 147
I have this formula in my VBA:
Currenstock = Application.WorksheetFunction.VLookup(Range("G2").Value, Sheets("Producten").Range("B1:D9000"), 2, False)
MsgBox (Currentstock)
the msgbox does appear but it shows nothing in it.
When I do this with VLOOKUP in an excel cell instead (with the same values), it finds exactly what I wanted it to find.
My question is; why doesn't this first process return a value? Whenever I remove worksheetfunction it also doesn't work.
Upvotes: 0
Views: 728
Reputation: 46
The variable you are setting with your Vlookup function is spelt differently to the Variable your are trying to return in your messagebox.
Currenstock
vs Curren
tStock
Using Option Explicit
in your macro will help to catch these.
Upvotes: 3