+ Reply to Thread
Results 1 to 11 of 11

Using INDIRECT to refer to INDEX's output

  1. #1
    Registered User
    Join Date
    12-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Using INDIRECT to refer to INDEX's output

    As part of generating a list of matching values in an INDEX list, I've had the idea of checking the list from the last matching value's position and continuing down the list from there. I know the INDEX returns a cell value, but is there some way to access that or force it to output it so that another cell can use an INDIRECT reference to see 'where that got to', as such?

    Let me explain in more detail. I'm building an interactive character sheet for a roleplaying game, in which all of the abilities that a character would have are listed on a hidden sheet. The INDEX function references this sheet, and searches the entire sheet for items that match the class of the character via the following formula: =INDEX('Hidden Sheet'!A1:F4,MATCH(B2,'Hidden Sheet'!C1:C4,0),1,1). Now, this cell returns the value of the first matching value it finds on the hidden sheet, which is fair enough.

    Now, INDEX returns a cell reference, right? So, the cell underneath should be able to do the following: =INDEX((INDIRECT(A150)):'Hidden Sheet'!F4,MATCH(B2,'Hidden Sheet'!C1:C4,0),1,1). In theory, this should get the location that the last cell was referred to (which will be in the A column) as the starting value of the array, and then continue from there. Instead, it accesses the cell and gets the value of the INDEX function, and not the cell reference, meaning it just returns a big, fat #REF! error rather than doing as it's told.

    Can anyone suggest how to either rewrite the formula, so that the cell underneath returns the next value that matches the criteria, or to allow me to force the cell to return the value I want, so that the cell underneath can reference that and use it to continue the search?
    Last edited by Libelnon; 12-28-2013 at 02:22 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Using INDIRECT to refer to INDEX's output

    Hi and welcome to the forum

    Now, INDEX returns a cell reference, right?
    No, INDEX returns the contents of the cell found at the intersection of a given row and column
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Using INDIRECT to refer to INDEX's output

    If you want to "find" the results of that INDEX/MATCH, then you would need to make that result the criteria for the MATCH() in another I/M

  4. #4
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Using INDIRECT to refer to INDEX's output

    INDEX does return a reference to a cell. However it does not return a cell address (or name), which is the required input for INDIRECT. MATCH is most useful as FDibbins said.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  5. #5
    Registered User
    Join Date
    12-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Using INDIRECT to refer to INDEX's output

    Okay, as an extension of that, then, how can I use the MATCH function to return part of an array? So far I have this, but it returns an error and won't let me put it in: =INDEX(ADDRESS(MATCH(A150,'Hidden Sheet'!A1:A4,0),1,1,1,"Hidden Sheet"):'Hidden Sheet'!F4,MATCH(B2,'Hidden Sheet'!C1:C4,0),1,1)

  6. #6
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Using INDIRECT to refer to INDEX's output

    It seems to me that ADDRESS is what you are looking for as it seems you know the value your are looking for in an array. Something like this might be adaptable for your purposes.

    Array formula:

    If you know the value and enter it in C1 then this will find the value in an array returning an ABSOLUTE reference.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This will return a RELATIVE reference.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,705

    Re: Using INDIRECT to refer to INDEX's output

    If you want to return multiple values for multiple matches the normal way is to use an array formula like this

    =IFERROR(INDEX('Hidden Sheet'!A$1:A$4,SMALL(IF('Hidden Sheet'!C$1:C$4=B$2,ROW('Hidden Sheet'!C$1:C$4)-ROW('Hidden Sheet'!C$1)+1),ROWS(K$5:K5))),"")

    confirm with CTRL+SHIFT+ENTER and copy down column - if you run out of matches you get blanks - I'm assuming you put the first formula in K5, change the red part of the formula to match the start cell
    Audere est facere

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Using INDIRECT to refer to INDEX's output

    Quote Originally Posted by FDibbins View Post


    No, INDEX returns the contents of the cell found at the intersection of a given row and column
    INDEX does return a reference but depending on how it's used the reference is usually resolved to the cell value.

    A good example of how it returns a reference is in defining a dynamic range.

    =A1:INDEX(A:A,MATCH("zzzzz",A:A))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  9. #9
    Registered User
    Join Date
    12-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Using INDIRECT to refer to INDEX's output

    Quote Originally Posted by daddylonglegs View Post
    If you want to return multiple values for multiple matches the normal way is to use an array formula like this

    =IFERROR(INDEX('Hidden Sheet'!A$1:A$4,SMALL(IF('Hidden Sheet'!C$1:C$4=B$2,ROW('Hidden Sheet'!C$1:C$4)-ROW('Hidden Sheet'!C$1)+1),ROWS(K$5:K5))),"")

    confirm with CTRL+SHIFT+ENTER and copy down column - if you run out of matches you get blanks - I'm assuming you put the first formula in K5, change the red part of the formula to match the start cell
    Trying that solution, I've got a long list of potential values going from CL1 to CL78 as my array. This is the formula in CL2 onwards:=IFERROR(INDEX('Hidden Sheet'!A$1:A$4,SMALL(IF('Hidden Sheet'!C$1:C$4=B2,ROW('Hidden Sheet'!C$1:C$4)-ROW('Hidden Sheet'!C$1)+1),ROWS(CL$1:CL1))),"")

    CL1 has the following: =INDEX('Hidden Sheet'!A1:F4,MATCH(B2,'Hidden Sheet'!C1:C4,0),1,1).

    However, CL1 is returning exactly the same as the entire array of values underneath it. Can't seem to figure out why, either.

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,705

    Re: Using INDIRECT to refer to INDEX's output

    Start with this formula in CL1 (with nothing in the other cells)

    =IFERROR(INDEX('Hidden Sheet'!A$1:A$4,SMALL(IF('Hidden Sheet'!C$1:C$4=B2,ROW('Hidden Sheet'!C$1:C$4)-ROW('Hidden Sheet'!C$1)+1),ROWS(CL$1:CL1))),"")

    confirm with CTRL+SHIFT+ENTER and only copy down once you have done that

    Of course you are only referencing 4 rows of Hidden Sheet, I'm assuming you need to expand that

  11. #11
    Registered User
    Join Date
    12-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Using INDIRECT to refer to INDEX's output

    Worked a treat, thanks.

+ 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] VBA for creating Index-Match every 2 rows where INDEX refer to a different column per row
    By bisaya789 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2012, 03:46 AM
  2. Cannot refer to 'error' = #N/A cell output
    By heatwave in forum Excel General
    Replies: 4
    Last Post: 03-09-2011, 11:10 PM
  3. Using INDIRECT to refer to different workbooks
    By Govind in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 04:05 AM
  4. Using INDIRECT to refer to different workbooks
    By Ken Cobler in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  5. Using INDIRECT to refer to different workbooks
    By Ken Cobler in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

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