#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 78
Default Variable File Name

Hello,

What formula can I use to make the file name variable?
Ex: If my formula reads as follows:
SUMIFS([200902_UPS.xls]UPS_CSV_EXPORT!$G:$G,[200902_UPS.xls]UPS_CSV_EXPORT!$F:$F,A117)
For the month of February, the file name is 200902_UPS.xls.
I want to make the 200902 portion variable by referencing to a cell which
provides the month number so that in March, the name would be 200903.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Variable File Name

I do not have XL 2007, so this is untested, but it should work:

=SUMIFS(INDIRECT("'["&A1&"_UPS.xls]UPS_CSV_EXPORT'!$G:$G"),INDIRECT("["&A1&"_UPS.xls]UPS_CSV_EXPORT'!$F:$F"),A117)

Where A1 contains you month values such as 200902 (I'd recommend including
the year so you don't have to worry about leading zeros.)
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Tigerxxx" wrote:

Hello,

What formula can I use to make the file name variable?
Ex: If my formula reads as follows:
SUMIFS([200902_UPS.xls]UPS_CSV_EXPORT!$G:$G,[200902_UPS.xls]UPS_CSV_EXPORT!$F:$F,A117)
For the month of February, the file name is 200902_UPS.xls.
I want to make the 200902 portion variable by referencing to a cell which
provides the month number so that in March, the name would be 200903.

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,104
Default Variable File Name

Should that read:
SUMIFS([200902_UPS.xls]UPS_CSV_EXPORT!$G:$G, A117,
[200902_UPS.xls]UPS_CSV_EXPORT!$F:$F)
As the syntax is =SUMIF( range, criteria, sum-range)

My answer mirros Luke's but has a slightly different approach
In A1 I have ="["&YEAR(TODAY())&TEXT(MONTH(TODAY()),"00")&"_UPS.xl s]"
This generates 200903
In A2 I have: UPS_CSV_EXPORT!
In A3 the formula =A1&A2&"$G:$G" generates
[200903_UPS.xls]UPS_CSV_EXPORT!$G:$G

In A4 the formula =A1&A2&"$F:$F" generates
[200903_UPS.xls]UPS_CSV_EXPORT!$F:$F

And finally in A5 I use =SUMIF(INDIRECT(A3),A117,INDIRECT(A4))
to get the right answer
best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Tigerxxx" wrote in message
...
Hello,

What formula can I use to make the file name variable?
Ex: If my formula reads as follows:
SUMIFS([200902_UPS.xls]UPS_CSV_EXPORT!$G:$G,[200902_UPS.xls]UPS_CSV_EXPORT!$F:$F,A117)
For the month of February, the file name is 200902_UPS.xls.
I want to make the 200902 portion variable by referencing to a cell which
provides the month number so that in March, the name would be 200903.

Thank you



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Variable File Name

If that sending file is closed, then =indirect() won't work. =indirect()
requires that the sending workbook be open.

If that's a problem, then Laurent Longre has an addin (morefunc.xll) at:
http://xcell05.free.fr/
or
http://xcell05.free.fr/morefunc/english/index.htm

That includes =indirect.ext() that may help you.

And to make matters worse, =sumif() in xl2003 and below won't work with
=indirect(). I don't know about xl2007 and I don't know about xl2007's
=sumifs().

But there are alternatives if it doesn't. You can use =sumproduct(). (But that
can't use entire columns until xl2007.)



Tigerxxx wrote:

Hello,

What formula can I use to make the file name variable?
Ex: If my formula reads as follows:
SUMIFS([200902_UPS.xls]UPS_CSV_EXPORT!$G:$G,[200902_UPS.xls]UPS_CSV_EXPORT!$F:$F,A117)
For the month of February, the file name is 200902_UPS.xls.
I want to make the 200902 portion variable by referencing to a cell which
provides the month number so that in March, the name would be 200903.

Thank you


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 78
Default Variable File Name

Thank you Luke, Bernard, Dave...the solutions are pretty interesting. I will
try them out!

"Dave Peterson" wrote:

If that sending file is closed, then =indirect() won't work. =indirect()
requires that the sending workbook be open.

If that's a problem, then Laurent Longre has an addin (morefunc.xll) at:
http://xcell05.free.fr/
or
http://xcell05.free.fr/morefunc/english/index.htm

That includes =indirect.ext() that may help you.

And to make matters worse, =sumif() in xl2003 and below won't work with
=indirect(). I don't know about xl2007 and I don't know about xl2007's
=sumifs().

But there are alternatives if it doesn't. You can use =sumproduct(). (But that
can't use entire columns until xl2007.)



Tigerxxx wrote:

Hello,

What formula can I use to make the file name variable?
Ex: If my formula reads as follows:
SUMIFS([200902_UPS.xls]UPS_CSV_EXPORT!$G:$G,[200902_UPS.xls]UPS_CSV_EXPORT!$F:$F,A117)
For the month of February, the file name is 200902_UPS.xls.
I want to make the 200902 portion variable by referencing to a cell which
provides the month number so that in March, the name would be 200903.

Thank you


--

Dave Peterson

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 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
Referring to a variable file name Brettjg Excel Discussion (Misc queries) 4 March 3rd 07 11:18 AM
Variable File Name [email protected] Excel Worksheet Functions 1 June 18th 06 10:36 AM
Inport from a variable file name shikamikamoomoo Excel Discussion (Misc queries) 1 March 22nd 06 12:29 AM


All times are GMT +1. The time now is 09:52 AM.

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"