Newbie here trying to find code examples online. I tried searching for this answer, but couldn't find something that worked -
Trying to use lookup to pull specific values from a table from a different sheet.
Sheet6 (Test) has:
A2:A5 = Red, Green, Blue, Yellow.
B2:B5 = Apple, Banana, Berry, Lemon
A9 (The lookup value) = Blue
and I'd like VBA to enter "Berry" into B9.
The code I tried is:
Sub VBA_Lookup1()
Range("B9").value = worksheetfunction.lookup(Range("A9").value,Range("A2:A5"),Range("B2:B5"))
End Sub
When run I get the error message "unable to get the lookup property of the worksheetfunction class"
Ultimately, I'd like the lookup value to be in one sheet, and the table to be in another, but I can't even get it to work in test.
Also, if there's a find or other function that would work better than lookup, I'm all ears!