I'm using a common "Last Row" formula in a VBA macro and it is not working in a "Vlookup" formula even though it works in a "Range Formula".
The lastrow formula is:
Dim LstRw As Long
LstRw = Range("A:CB").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
This works in the "Range Formula":
Range("H2").AutoFill Range("H2:H" & LstRw)
It does not work in the "Vlookup Formula"
Range("I2").Formula = "=""Company_""&VLOOKUP(E2,$G$2:$H&LstRw,2,0)"
If I remove the "LstRw" and replace it with a real row number the formula will work however, I need it to be dynamic as the quantity of row numbers will change daily.
Would anyone know how to correct this??
Thank You,
JB
The lastrow formula is:
Dim LstRw As Long
LstRw = Range("A:CB").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
This works in the "Range Formula":
Range("H2").AutoFill Range("H2:H" & LstRw)
It does not work in the "Vlookup Formula"
Range("I2").Formula = "=""Company_""&VLOOKUP(E2,$G$2:$H&LstRw,2,0)"
If I remove the "LstRw" and replace it with a real row number the formula will work however, I need it to be dynamic as the quantity of row numbers will change daily.
Would anyone know how to correct this??
Thank You,
JB