Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Calling variable file name

I have a macro that inserts a vlookup referencing from
another file, the problem i am having is that the
reference file has a different name each time the macro is
run. The reference file name is "Consolidted" followed by
the creation date.
Cells(i, "E").FormulaR1C1 = _
"=VLOOKUP(RC1,'[Consolidated 120903.xls]Sheet1'!
C2:C36,18,0)"

The creation date is referenced on "Sheet1" range "A1" of
the Consolidated file. I have tried using a "MyFile" name
but can not make it work. Any help would be greatly
appreciated

Thanks
Michael
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Calling variable file name

Cells(i, "E").FormulaR1C1 = _
"=VLOOKUP(RC1,'[Consolidated " & _
Range("Sheet1!A1").Value & _
".xls]Sheet1'!R2C3:R36C21,18,0)"

If you are going to use FormulaR1C1, all your references need to be in R1C1
notation.

If you are going to return the value from column 18 in the lookup range, you
need to have a lookup range that is at least 18 columns wide.

--
Regards,
Tom Ogilvy



"Michael" wrote in message
...
I have a macro that inserts a vlookup referencing from
another file, the problem i am having is that the
reference file has a different name each time the macro is
run. The reference file name is "Consolidted" followed by
the creation date.
Cells(i, "E").FormulaR1C1 = _
"=VLOOKUP(RC1,'[Consolidated 120903.xls]Sheet1'!
C2:C36,18,0)"

The creation date is referenced on "Sheet1" range "A1" of
the Consolidated file. I have tried using a "MyFile" name
but can not make it work. Any help would be greatly
appreciated

Thanks
Michael



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Calling variable file name

Tom
Many thanks for your help, all is now working.

Thanks again
Michael
-----Original Message-----
Cells(i, "E").FormulaR1C1 = _
"=VLOOKUP(RC1,'[Consolidated " & _
Range("Sheet1!A1").Value & _
".xls]Sheet1'!R2C3:R36C21,18,0)"

If you are going to use FormulaR1C1, all your references

need to be in R1C1
notation.

If you are going to return the value from column 18 in

the lookup range, you
need to have a lookup range that is at least 18 columns

wide.

--
Regards,
Tom Ogilvy



"Michael" wrote in message
...
I have a macro that inserts a vlookup referencing from
another file, the problem i am having is that the
reference file has a different name each time the macro

is
run. The reference file name is "Consolidted" followed

by
the creation date.
Cells(i, "E").FormulaR1C1 = _
"=VLOOKUP(RC1,'[Consolidated 120903.xls]Sheet1'!
C2:C36,18,0)"

The creation date is referenced on "Sheet1" range "A1"

of
the Consolidated file. I have tried using a "MyFile"

name
but can not make it work. Any help would be greatly
appreciated

Thanks
Michael



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling name of Sheet as a Variable? thekeytothedoor Excel Worksheet Functions 1 January 1st 10 08:48 AM
calling a value from another file using a variable in the file nam DA_Potts[_2_] Excel Worksheet Functions 3 December 3rd 07 12:25 AM
calling a value from another file using a variable in the file nam DA_Potts[_2_] Excel Discussion (Misc queries) 4 December 2nd 07 11:09 PM
Calling a procudure through variable name Basu Excel Discussion (Misc queries) 2 August 30th 06 08:55 AM
saveas calling a variable Douvid Excel Programming 6 July 28th 03 08:46 AM


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"