Results 1 to 11 of 11

Return range name from concatenated strings

Threaded View

  1. #1
    Registered User
    Join Date
    03-29-2010
    Location
    Earth
    MS-Off Ver
    Excel 2007
    Posts
    37

    Return range name from concatenated strings

    I have financial data of various accounts stored in Workbook A.

    Workbook B defines a number of ranges as follows to access the data stored in Workbook A:

    dPath = path to Workbook A

    dFN1 = filename of Workbook A and worksheet name of sheet where Company 1's data is stored

    dAc5000 = range of data for account 5000 (eg "$F$6:$F$37")
    dAc5010 = range of data for account 5000 (eg "$G$6:$G$37")
    etc

    dDate = range of dates corresponding to the account data

    Workbook B sets out the account data in rows by looking up a date in row 1 and matching it to a corresponding date in a named range in Workbook A. The following formula is an example:

    =IF(ISNA(INDEX(INDIRECT(dPath&dFn1&dAc5000),MATCH(TEXT(G$1,"dd/mm/yyyy"),INDIRECT(dPath&dFn1&dDate),0))),0,INDEX(INDIRECT(dPath&dFn1&dAc5000),MATCH(TEXT(G$1,"dd/mm/yyyy"),INDIRECT(dPath&dFn1&dDate),0)))

    Using this kind of formula, I get the desired result, but the different account range names must be hard-coded into the formulae on each row.

    Instead of hard-coding the name dAc5000 into the above formula, I would like to have a generic formula that can be included on each row, and the data retrieved from Workbook A for a particular row dependant on the contents of a separate column that includes an account number (called, say, AcNo). This way I could change the layout/order of the rows simply by changing the account numbers in the AcNo column, without having to alter the formulae in each row.

    I have tried concatenating the string "dAc" to the contents of column AcNo, and using the returned string as an alternative range name in the above formula. For example, for row 5000, the string returned is dAc5000 (the same string as the named range already defined), so I adjusted the INDIRECT portion of the above formula to:

    INDIRECT(dPath&dFn1&"dAc"&AcNo)

    Unfortunately this results in a #REF! error, I think because the concatenation returns a string and not the corresponding named range. (Note, the external worksheet is open, and so the #REF! error is not because the external worksheet is closed.)

    Thanks in advance for any help.
    Last edited by cad1llac; 03-30-2010 at 01:56 AM.

Thread Information

Users Browsing this Thread

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

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