+ Reply to Thread
Results 1 to 16 of 16

Need help with same formula but different file names

  1. #1
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Need help with same formula but different file names

    I have a simple formula that references a certain cell on a certain tab of one of our budget templates.

    ='G:\Annual Budgs\2015 Budget\Budget Files\[12345.xlsm]DirectCost'!$R$76

    The 12345 part of the file name is actually the department that the budget template is for.

    I then have a list of deparments:

    Department Direct Cost
    21311 ='G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76
    12346 ='G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76
    67859 ...
    12348
    12349

    How can I write a formula to replace 12345.xlsm in the formula above with the next deparment, i.e. ='G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76

    I have about 500 departments and I have been copying the formula all the way down, then going in between the brackets on each line and changing each single one to the department number. There has to be a better way to incorporate the text into the file name somehow via a cell reference.

    Any ideas would be greatly appreciated.

    Thank you.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Need help with same formula but different file names

    Try ...

    =INDIRECT("'G:\Annual Budgs\2015 Budget\Budget Files\[" & A1 & ".xlsm]DirectCost'!$R$76")

    A1=Department

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need help with same formula but different file names

    Try this formula in C1 and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Row\Col
    A
    B
    C
    D
    1
    21311
    G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 In C1 :=SUBSTITUTE(B1,"12346",A1)
    2
    12346
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76
    3
    67859
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[67859.xlsm]DirectCost'!$R$76
    4
    12348
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12348.xlsm]DirectCost'!$R$76
    5
    12349
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12349.xlsm]DirectCost'!$R$76
    Dave

  4. #4
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    This gives me a #REF error

  5. #5
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    Quote Originally Posted by FlameRetired View Post
    Try this formula in C1 and fill down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Row\Col
    A
    B
    C
    D
    1
    21311
    G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 In C1 :=SUBSTITUTE(B1,"12346",A1)
    2
    12346
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76
    3
    67859
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[67859.xlsm]DirectCost'!$R$76
    4
    12348
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12348.xlsm]DirectCost'!$R$76
    5
    12349
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12349.xlsm]DirectCost'!$R$76
    This returns the value that is in B from my formula

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need help with same formula but different file names

    This formula is more "generic". It SUBSTITUTEs whatever 5 character text is the filename with those in column A.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Row\Col
    A
    B
    C
    D
    1
    21311
    G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 In C1 :=SUBSTITUTE(B1,MID(B1,FIND("[",B1)+1,5),A1)
    2
    12346
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76
    3
    67859
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[67859.xlsm]DirectCost'!$R$76
    4
    12348
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12348.xlsm]DirectCost'!$R$76
    5
    12349
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12349.xlsm]DirectCost'!$R$76

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need help with same formula but different file names

    Quote Originally Posted by Excel Jockey View Post
    This returns the value that is in B from my formula
    The first one would. It was my understanding you want "12346" replaced by what is in column A. Is it another way?

  8. #8
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    I don't know if this would help but my formula brings in the direct cost in cell R76 of the Direct Cost tab of the budget template it references. Colum B in the above example from FlameRetired will actually have the value from cell R76.

  9. #9
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    Quote Originally Posted by FlameRetired View Post
    The first one would. It was my understanding you want "12346" replaced by what is in column A. Is it another way?
    Here is what it does when I drag it down:
    804598 Small Engine Test $2,934,138.72 2934138.71579901
    800588 Small Gears $2,934,138.72 2934138.71579901
    800591 Special Processes $2,934,138.72 2934138.71579901
    801553 Special Processes $2,934,138.72 2934138.71579901
    801554 Special Processes $2,934,138.72 2934138.71579901
    803553 Special Processes $2,934,138.72 2934138.71579901
    803563 Special Processes $2,934,138.72 2934138.71579901
    803567 Special Processes $2,934,138.72 2934138.71579901
    803574 Special Processes $2,934,138.72 2934138.71579901

  10. #10
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    Quote Originally Posted by JohnTopley View Post
    Try ...

    =INDIRECT("'G:\Annual Budgs\2015 Budget\Budget Files\[" & A1 & ".xlsm]DirectCost'!$R$76")

    A1=Department
    This gives me #REF error

    804592 Small Engine Assembly #REF!

  11. #11
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    Quote Originally Posted by FlameRetired View Post
    This formula is more "generic". It SUBSTITUTEs whatever 5 character text is the filename with those in column A.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Row\Col
    A
    B
    C
    D
    1
    21311
    G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[21311.xlsm]DirectCost'!$R$76 In C1 :=SUBSTITUTE(B1,MID(B1,FIND("[",B1)+1,5),A1)
    2
    12346
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76
    3
    67859
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[67859.xlsm]DirectCost'!$R$76
    4
    12348
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12348.xlsm]DirectCost'!$R$76
    5
    12349
    G:\Annual Budgs\2015 Budget\Budget Files\[12346.xlsm]DirectCost'!$R$76 G:\Annual Budgs\2015 Budget\Budget Files\[12349.xlsm]DirectCost'!$R$76
    This one gives me #VALUE

    804598 Small Engine Test $2,934,138.72 #VALUE!
    800588 Small Gears $2,934,138.72 #VALUE!
    800591 Special Processes $2,934,138.72 #VALUE!
    801553 Special Processes $2,934,138.72 #VALUE!
    801554 Special Processes $2,934,138.72 #VALUE!
    803553 Special Processes $2,934,138.72 #VALUE!

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need help with same formula but different file names

    Here's the results file of both formulas I posted.

    Perhaps if you upload a sample Excel file showing what you are starting with and then in the next column showing us the expected results (hand typed if necessary) this would be easier for us to understand.
    Last edited by FlameRetired; 10-09-2015 at 02:29 PM. Reason: rewording

  13. #13
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    Quote Originally Posted by Excel Jockey View Post
    Here is what it does when I drag it down:
    804598 Small Engine Test $2,934,138.72 2934138.71579901
    800588 Small Gears $2,934,138.72 2934138.71579901
    800591 Special Processes $2,934,138.72 2934138.71579901
    801553 Special Processes $2,934,138.72 2934138.71579901
    801554 Special Processes $2,934,138.72 2934138.71579901
    803553 Special Processes $2,934,138.72 2934138.71579901
    803563 Special Processes $2,934,138.72 2934138.71579901
    803567 Special Processes $2,934,138.72 2934138.71579901
    803574 Special Processes $2,934,138.72 2934138.71579901
    This formula looks like it should work but for whatever reason returns the value that is in C:

    804598 Small Engine Test $2,934,138.72 2934138.71579901 =SUBSTITUTE(C1,"804599",A1)
    800588 Small Gears $2,934,138.72 2934138.71579901 =SUBSTITUTE(C2,"804599",A2)
    800591 Special Processes $2,934,138.72 2934138.71579901 =SUBSTITUTE(C3,"804599",A3)

  14. #14
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    Quote Originally Posted by FlameRetired View Post
    Here's the results file of both formulas I posted.

    Perhaps if you upload a sample Excel file showing what you are starting with and then in the next column showing us the expected results (hand typed if necessary) this would be easier for us to understand.
    Hi Dave,

    Your worksheet has text in column B so column C would substitute the text but my column B is an actual formula that brings in the value in the cell it is referencing, but using your formula with my formula in B just returns the value.

    I need a formula that will replace the file name in the formula with the department in column A. I will load a sample sheet here in a minute.

  15. #15
    Registered User
    Join Date
    10-09-2015
    Location
    Indianapolis, IN
    MS-Off Ver
    2010
    Posts
    10

    Re: Need help with same formula but different file names

    Attached is the sample data with how it looks now and how I would like it to look.

    Thanks.
    Attached Files Attached Files

  16. #16
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Need help with same formula but different file names

    Quote Originally Posted by Excel Jockey View Post
    ...... but my column B is an actual formula that brings in the value in the cell it is referencing, but using your formula with my formula in B just returns the value.

    I need a formula that will replace the file name in the formula with the department in column A..
    That's clearer. I'll have a look at your upload.

    Edit If you insert / replace references to B1 with your formula itself it should work. The formula I posted works on whatever is passed to it whether it be cell reference, result of another formula or a literal text string. I would upload a workbook demonstrating how this works but I cannot reference those files directly to demonstrate by another formula. All I have to access those formulas is a function new to Excel 2013. It will not work in 2010 your profile states. Do you have otherwise access to Excel 2013?

    Hand typing in each of those "='L:\Finance\Annual Budgs\2015 Budget\Budget Files\[8045988.xlsm]DirectCost'!$R$76" is going to be a drag I'm sure. So if there is a formula you are using that can generate the same results insert that in place of B1 and fill down.

    Keep us posted please.
    Last edited by FlameRetired; 10-09-2015 at 03:33 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Referencing other workbook file names by formula
    By billyshears in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-29-2013, 10:22 AM
  2. [SOLVED] Flagging formula for file names that do not occur a set number of times
    By njmiller31 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-23-2012, 09:34 PM
  3. Replies: 1
    Last Post: 05-14-2012, 10:14 AM
  4. read in folder names and file names
    By gshock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2011, 12:45 PM
  5. Create array of file names/sheet names
    By BVHis in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-06-2008, 11:30 AM
  6. How to update formula with different file names?
    By tfcc in forum Excel General
    Replies: 1
    Last Post: 04-08-2005, 09:15 AM
  7. [SOLVED] Path names to xla file in formula
    By Carl L in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-04-2005, 03:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1