Hi all,
New to VBA, learning a lot already. Here's my situation:
I'm trying to write a vlookup where I know what the text in the first and last cells in my table array are, but not their cell address.
I've tried to fix it by using a variable for my table array.
I get "compile error: expected: expression" at the & when setting vla1. i'll accept other solutions. the goal is for the table array portion of vlookup to find itself based on the fact that the first cell will say C.I. and the last cell will say 17200. these cells will be located in A:A and B:B respectively
New to VBA, learning a lot already. Here's my situation:
I'm trying to write a vlookup where I know what the text in the first and last cells in my table array are, but not their cell address.
I've tried to fix it by using a variable for my table array.
Code:
Sub vl()
Dim vl1 As Range
Set vl1 = Range("A:A").Find("C.I.")
Dim vl2 As Range
Set vl2 = Range("B:B").Find("17200")
Dim vl1a As Range
set vl1a = range(&vl1, &vl2)
MsgBox vl1a
ActiveCell.Formula = "=VLOOKUP(G5," & vl1a & ",2)*H5"
End Sub
I get "compile error: expected: expression" at the & when setting vla1. i'll accept other solutions. the goal is for the table array portion of vlookup to find itself based on the fact that the first cell will say C.I. and the last cell will say 17200. these cells will be located in A:A and B:B respectively