I'm trying to lookup a value on a spreadsheet within a table array using the VLOOKUP function in my vba code. I don't know how to write it correctly.
Here is the normal VLOOKUP formula with all the references:
=VLOOKUP(DATA!AN2,DATA!AA9:AF20,5,FALSE)
VLOOKUP is one of the most useful and versatile functions in Excel. As you work further with macros it's not uncommon to make your create an Excel VBA VLOOKUP macro. With this you get the ability to reference your tables of data, but automated.
Have you tried:
Dim result As String Dim sheet As Worksheet Set sheet = ActiveWorkbook.Sheets("Data") result = Application.WorksheetFunction.VLookup(sheet.Range("AN2"), sheet.Range("AA9:AF20"), 5, False)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With