Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way:
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],'[" & myFile & _ "]TOTAL'!R1C1:R548C11, 10, FALSE)" In article , JEFFWI wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You were missing the double quotes
ActiveCell.FormulaR1C1 = _ "=VLOOKUP(RC[-16],'[" & myFile & "]TOTAL'!R1C1:R548C11, _ 10, FALSE)" "JEFFWI" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My previous posting would of had a errror becausse of the line continuation.
You were missing the doulble quotes. ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],'[" &myFile & _ "]TOTAL'!R1C1:R548C11, 10, FALSE)" "JEFFWI" wrote: 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Joel and JE! I am getting this to work but Excel 2003 is doing
something funny when i parses this. It doesn't seem to reference the sheet correctly. The contents of the active cell look something like: =VLOOKUP('A1','C:\Documents and Settings\Jeff\My Documents\[testvlookup2.xlsTOTAL]testvlookup2'!$A$1:$A$12, 10, FALSE) TOTAL is a tab on a worksheet. Any idea on what Excel is thinking when it parses like this? Thanks again! Jeff "Joel" wrote: My previous posting would of had a errror becausse of the line continuation. You were missing the doulble quotes. ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],'[" &myFile & _ "]TOTAL'!R1C1:R548C11, 10, FALSE)" "JEFFWI" wrote: 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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're mixing R1C1 reference style with A1 reference style.
Either use: ActiveCell.FormulaR1C1 = ... or ActiveCell.Formula = ... But don't mix them. JEFFWI wrote: Thanks Joel and JE! I am getting this to work but Excel 2003 is doing something funny when i parses this. It doesn't seem to reference the sheet correctly. The contents of the active cell look something like: =VLOOKUP('A1','C:\Documents and Settings\Jeff\My Documents\[testvlookup2.xlsTOTAL]testvlookup2'!$A$1:$A$12, 10, FALSE) TOTAL is a tab on a worksheet. Any idea on what Excel is thinking when it parses like this? Thanks again! Jeff "Joel" wrote: My previous posting would of had a errror becausse of the line continuation. You were missing the doulble quotes. ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-16],'[" &myFile & _ "]TOTAL'!R1C1:R548C11, 10, FALSE)" "JEFFWI" wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
set a variable based on a vlookup | Excel Discussion (Misc queries) | |||
Variable col_index_num in vlookup | Excel Discussion (Misc queries) | |||
using variable names in VLOOKUP | Excel Programming | |||
vlookup using a variable | Excel Programming | |||
variable vlookup | Excel Programming |