View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JEFFWI JEFFWI is offline
external usenet poster
 
Posts: 7
Default Using a variable for the 2nd paremeter in a vlookup

Greetings,

I have a variable called myFile$ in my VBA that contains a file name. I
want to use it in the following VLookUp.

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],'[&myFile&]TOTAL'!R1C1:R548C11,
10, FALSE)"

When I run my script the variable doesn't resolve to the actual contents of
the variable. Instead I get a dialog box prompting me with "Update Values:"
as the title. When I cancel the ActiveCell indeed confirms that the vlookup
formula contains &myFile& as the second parameter.

The reason I need this is because my range for param 2 to vlookup is in a
different file everytime i run my macro.

Can someone advise as to a better way to do this and/or point me to some
documentation?

Thank you very much!
Jeff