• Passing tab name into formula (2000)

    Author
    Topic
    #383919

    Is it possible to pass a tab name from a cell location into a formula?

    i.e.
    =IF(ISERROR(VLOOKUP($C98,'[Mincron Data.xls]xDec’!$A:$C,2,FALSE))=TRUE,””,VLOOKUP($C98,'[Mincron Data.xls]xDec’!$A:$C,2,FALSE))

    This lookup grabs information from another workbook (Mincron Data.xls) with separate sheets labeled xJan, xFeb, xMar, ………..
    I’d like the formula to select the correct sheet based on the content of a cell at the top of the column with the formula. I’ve tried

    Viewing 1 reply thread
    Author
    Replies
    • #656537

      You need the =INDIRECT() function, as in

      =INDIRECT(“‘[Mincron Data.xls]xDec’!$A:$C”)

      Review INDIRECT in Excel Help and search here in the Excel Forum for examples.

      • #656548

        One thing to remember:
        When using the indirect to get info from ANOTHER workbook, the other workbook MUST be open. Indirect will NOT work with closed workbooks, so it can NOT link to the workbook like typing the name in directly.
        Steve

        • #656552

          For the original poster, the preferred method of handling this issue is to directly embed the linking formula into another cell or cells in the Workbook, such as:

          Cell X1 contains =VLOOKUP($C98,'[Mincron Data.xls]xDec’!$A:$C,2,FALSE)
          Cell X2 contains =VLOOKUP($C100,'[Other Data.xls]YEAR’!$A:$C,2,FALSE)

          And then using local functions or IF statements to return what you want:

          =IF(condition,X1,X2)

          … all hypothetical.

    • #656570

      Thanks for the quick response. I’m not sure whether my question was quite clear. Please take a look at the sample.

      • #656639

        Hi Zeno,

        As per the advice from John & Steve, your formula would need an INDIRECT statement to build the link to a tab via the reference in P10 to the open source worksheet. To do this, you would replace:
        ‘P:MeloneJ[Mincron Data.xls]xDec’!$A:$C
        in your formulae with
        INDIRECT(“‘P:MeloneJ[Mincron Data.xls]”&P$10&”‘!$A:$C”)

        You could get around the limitation that INDIRECT only works if the source workbook is open by having a set of worksheets in the one you’re using that explicitly link to the corresponding ranges in “‘P:MeloneJ[Mincron Data.xls”, and giving each of those worksheets the tabs described on row 10. Then you could replace
        ‘P:MeloneJ[Mincron Data.xls]xDec’!$A:$C
        in your formulae with
        INDIRECT(P$10&”‘!$A:$C”)

        Cheers

        PS: The formula
        =”x”&TEXT(P11,”mmm”)
        on P10 could be simplified to
        TEXT(P11,”xmmm”)

        Cheers,
        Paul Edstein
        [Fmr MS MVP - Word]

        • #656647

          Zeno, Steve and Macropod are steering you straight; I had taken a quick look at the spreadsheet you posted but then the powers that sign my paycheck required my time. grin One other approach considering Steve’s excellent warning is to create a table (like this fictitious one) in the same workbook as the one you posted (same or different sheet) that links to the other workbooks like this:

          G H
          1 xJan ='[MyJan.xls]Sheet1′!$A$1
          2 xFeb ='[MyFeb.xls]Sheet1′!$A$1
          3 xMar ='[MyMar.xls]Sheet1′!$A$1
          4 xApr ='[MyApr.xls]Sheet1′!$A$1
          5 xMay ='[MyMay.xls]Sheet1′!$A$1
          6 xJun ='[MyJun.xls]Sheet1′!$A$1
          7
    Viewing 1 reply thread
    Reply To: Passing tab name into formula (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: