+ Reply to Thread
Results 1 to 5 of 5

Insert CONCATENATE-generated file path into IF formula

  1. #1
    Registered User
    Join Date
    10-11-2013
    Location
    Belfast
    MS-Off Ver
    Excel 2007 Windows
    Posts
    2

    Question Insert CONCATENATE-generated file path into IF formula

    Hello all!

    Say I have the following formula, which gives me either 1 or 0 as a result of finding "CAT" within a particular range in an external workbook.

    =IF('\\root\201310\[Source20131011.xls]Data'!F1:F20="CAT",1,0)

    That works fine. Except that the file name and location change everyday, following the current date.

    So I came up with this:

    =CONCATENATE("\\root\",Z1&Z2,"\[Source",Z1&Z2&Z3,".xls]")

    This displays the correct path and filename, corrected daily. The output, in this example, is \\root\201310\[Source20131011.xls], provided that Z1, Z2 and Z3 are cells containing year, month and day respectively.

    Now here's where I get stuck. How can I insert this path, which I just generated in the second formula, into the first formula? I tried a lot of stuff, but there seems to be something very wrong with including the CONCATENATE function (or a reference to another cell where the CONCATENATE function is) into the =IF formula.

    I've seen some people resolve similar problems using INDIRECT, but that doesn't seem to do the trick for searching inside an entire range of the external file - which I need to be able to do.

    Any help much appreciated.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Insert CONCATENATE-generated file path into IF formula

    Can you post the formula you tried using indirect, that would be the go-to method for this sort of problem...

  3. #3
    Registered User
    Join Date
    10-11-2013
    Location
    Belfast
    MS-Off Ver
    Excel 2007 Windows
    Posts
    2

    Re: Insert CONCATENATE-generated file path into IF formula

    Something like this:

    =INDIRECT("'"&B1&"Data"&"'!$H$2:$H$30000")

    Where B1 holds the CONCATENATE function, and currently displays the referred file path: \\root\201310\[Source20131012.xls]

    All I get from that INDIRECT function is #REF!
    No difference if I actually type the file path in the formula instead of referring to the B1 cell.

    No idea why this doesn't work, it seems like a textbook example of INDIRECT. The only thing is I'm using Excel for Mac - not sure if that matters.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Insert CONCATENATE-generated file path into IF formula

    Well it looks ok to me so first thing to check I guess is do you still get a #REF! error if you type this in a cell?
    ='\\root\201310\[Source20131012.xls]Data'!$H$2:$H$30000

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Insert CONCATENATE-generated file path into IF formula

    INDIRECT does not work with files that are closed.

    Pete

+ 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. [SOLVED] how to insert file path of every file in a folder as a string?
    By Gamekiller48 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-31-2013, 02:01 PM
  2. Open from dialog box to insert file path and name into cell
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2012, 02:29 AM
  3. Insert file path & name to a cell
    By mvel_sky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2009, 03:56 AM
  4. Insert a file path at bottom of page with no [sheet1]
    By Ewane in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2006, 05:25 PM
  5. How do I insert the directory path in my Excel file?
    By Insert a Directory Path in Hea in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-04-2005, 08: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