+ Reply to Thread
Results 1 to 16 of 16

Problem with Indirect Function

  1. #1
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Problem with Indirect Function

    I'm trying to use the indirect function to link to a cell in an open workbook. The Workbook I'm trying to link to is called Table.xls. Here is what I have in the main workbook ...

    cell A2 = Table.xls
    cell A3 = Sheet1
    cell A4 = C5

    cell A7 = =INDIRECT(" ' [" & A2 & " ] " & A3 & " ' ! " & A4)

    this should access cell C5 on Sheet1 of Table.xls file but it returns #REF error in cell A7 for some reason. I have both workbooks open so I know that isn't the reason. Is there a setting or something I need to change to get this to work? Any help is appreciated. Thanks.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Problem with Indirect Function

    You appear to have unwanted spaces:
    =INDIRECT("'[" & A2 & "]" & A3 & "'!" & A4)
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Problem with Indirect Function

    Also the source workbook must be open for it to work!
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Problem with Indirect Function

    Quote Originally Posted by romperstomper View Post
    You appear to have unwanted spaces:
    =INDIRECT("'[" & A2 & "]" & A3 & "'!" & A4)

    Sorry, I just added the spaces to clear up the whole " vs. ' thing. This is what I actually have in A7...=INDIRECT("'[" & A2 & "]" & A3 & "'!" & A4)

  5. #5
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Problem with Indirect Function

    Quote Originally Posted by NBVC View Post
    Also the source workbook must be open for it to work!
    Both workbooks are open and I'm still getting the #REF error.

  6. #6
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Problem with Indirect Function

    Quote Originally Posted by NBVC View Post
    Also the source workbook must be open for it to work!
    Both workbooks are open and I'm still getting the #REF error.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Problem with Indirect Function

    Are they open in the same instance of Excel? (they need to be)

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Problem with Indirect Function

    It worked perfect for me when both workbooks are in same instance.

    Double-check spelling of workbook and sheet name too.

  9. #9
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Problem with Indirect Function

    Quote Originally Posted by romperstomper View Post
    Are they open in the same instance of Excel? (they need to be)
    Yes they are!

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Problem with Indirect Function

    After checking spelling matches... (making sure no extra spaces are at the end of the A2:A4 cells and the actual workbook and worksheet names... make sure that it is actually A2 that house the workbook name, A3 that has the sheetname and A4 that has the cell reference. For me it works fine.

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Problem with Indirect Function

    I assume there isn't a #REF! error in that cell in the source workbook?
    If not, can you enter a direct link to the other cell, then copy the exact formula from the formula bar and paste it here?

  12. #12
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Problem with Indirect Function

    I deleted the ".xls" from the file name in A2 and it worked. Does anybody know why?

    Based on this website (http://www.contextures.com/xlFunctions05.html) the .xls should be in the cell.

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Problem with Indirect Function

    It worked for me with both Table.xls and just Table in A2.

    If it is in XL2007 you are working should it have been Table.xlsx in A2?

    Leaving the .xls or .xlsx off makes it default to the current applications extension.
    Last edited by NBVC; 06-23-2011 at 12:21 PM. Reason: clarify

  14. #14
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Problem with Indirect Function

    table.xls in A2 returns #REF
    table in A2 works
    table.xlsx in A2 works

    Thanks for your help Romperstomper and NBVC

  15. #15
    Registered User
    Join Date
    05-20-2011
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Problem with Indirect Function

    Now to add a twist to the problem, what if I had multiple excel files called Table_1, Table_2, Table_3, etc.. and I wanted to use the indirect function to link to one of these files. So I would have...

    cell A2 = Table
    cell A3 = 1
    cell A4 = Sheet1
    cell A5 = C5

    which would access the file Table_1.xlsx

    How would I write that?

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Problem with Indirect Function

    Try:

    =INDIRECT("'[" & A2 & "_" & A3 & "]" & A4 & "'!" & A5)

    or


    =INDIRECT("'[" & A2 & "_" & A3 & ".xlsx]" & A4 & "'!" & A5) to force the .xlsx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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