-
Stuck on VLOOKUP VBA using variables
I've been struggling with this one for a few days now:
Trying to have vlookup in code search within a range, see below, I have first row cell and last row cell reference, however; those values are not working in vlookup for some reason.
'Obtain First cell
ActiveSheet.Cells(3, 3).Select
MyFirstRow = ActiveCell.Address
'Obtain Last Cell
ActiveSheet.Cells(3, 3).Select
Selection.End(xlDown).Select
MyLastRow = ActiveCell.Address
Selection.End(xlUp).Select
'Populate cell references
ActiveSheet.Cells(5, 8).Value = MyFirstRow
ActiveSheet.Cells(6, 8).Value = MyLastRow
ActiveSheet.Cells(3, 2).Select
ActiveCell.Formula = "=VLOOKUP($A1,MyFirstRow:MyLastRow,2,FALSE)"
My goal is the following:
LIST OF VALUES TO SEARCH:
ABC
DAA
FEE
FDC
EEE
RANGE:
ADK 1
DAL 2
ETT 5
ABC 3
Search all values within the range, I have a loop and works fine, just need to figure out how to reference vlookup using variables. Appreciate any help I can get, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules