+ Reply to Thread
Results 1 to 9 of 9

What's wrong with this Index Match/Row formula?

  1. #1
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    What's wrong with this Index Match/Row formula?

    Hi,

    I have an index match formula which works well in returning values from the first Column from a range (Columns G:K) if Column K contains and X The formula once copied down return all instances (2 instances below) and shows a blank for error handling when it reaches the last data to return.

    ColumnG ColumnK

    9130 X

    2135

    6859 X

    =IF(ISERROR(INDEX(G:K,SMALL(IF(Sheet1!K:K="X",ROW(Sheet1!K:K)),ROW(1:1)),1)),"",INDEX(G:K,SMALL(IF(Sheet1!K:K="X",ROW(Sheet1!K:K)),ROW(1:1)),1))

    I'm trying to modify the formula to move to a new range (Columns N:R) when it finishes finding data from the first range. The formula I thought would work is below, excel isn't accepting it and I can't work out what's wrong.

    =IF((ISERROR(INDEX(G:K,SMALL(IF(Sheet1!K:K="X",ROW(Sheet1!K:K)),ROW(1:1)),1)),INDEX(N:R,SMALL(IF(Sheet1!R:R="X",ROW(Sheet1!R:R)),ROW(1:1)),1)),"")

    My aim to to have it run through upwards of 5 ranges of data, but I obviously can't proceed until I can get it working with two.

    Any help on this would be appreciated!

    Thanks

  2. #2
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    170

    Re: What's wrong with this Index Match/Row formula?

    It's harder to tell without an example of your worksheet, but try this:

    =IF((ISERROR(INDEX(G:K,SMALL(IF(Sheet1!K:K="X",ROW(Sheet1!K:K)),ROW(1:1)),1))),INDEX(N:R,SMALL(IF(Sheet1!R:R="X",ROW(Sheet1!R:R)),ROW(1:1)),1),"")

    I think you may have made a mistake with bracket placement.

  3. #3
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: What's wrong with this Index Match/Row formula?

    Hi cffndncr,

    It now seems to be returning values from the second range only, but not the first. I'll try and attach a sample to help.

    Thanks

  4. #4
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: What's wrong with this Index Match/Row formula?

    Sample.xlsx

    cffndncr, I've attached a sample with the colours being the rangers (currently 2) but ultimately more. The formula is to return the value in column G and N where an X appears in K or R respectively.

    I hope this makes a little sense.

    Cheers

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: What's wrong with this Index Match/Row formula?

    You could use this formula

    =IFERROR(IFERROR(INDEX(G:G,SMALL(IF(K:K="X",ROW(K:K)),ROW(1:1))),INDEX(N:N,SMALL(IF(R:R="X",ROW(N:N)),ROW(1:1)-COUNTIF(K:K,"x")))),"")

    ...so it uses the green part until it hits an error....and then the red part until it hits an error.....and then it gives you blanks.

    Notice that for the red part you need a COUNTIF to count the "x"s in the previous range and subtract that from ROW(1:1). If you add a third option you need to use two COUNTIFs to subtract the number of hits from both the first two ranges....and then if you have a 4th range you'll need 3 COUNTIFs etc. etc....

    I used the same formula setup that you had - but if I was doing this I wouldn't reference the whole column - that makes the calculations very slow.....and I wouldn't use ROW as you have used it because it's not very robust, if you add rows at the top of the sheet your results won't be correct.

    To make more robust I would use something like this:

    =IFERROR(IFERROR(INDEX(G$2:G$100,SMALL(IF(K$2:K$100="X",ROW(K$2:K$100)-ROW(K$2)+1),ROWS(D$2:D2))),INDEX(N$2:N$100,SMALL(IF(R$2:R$100="X",ROW(R$2:R$100)-ROW(R$2)+1),ROWS(D$2:D2)-COUNTIF(K$2:K$100,"x")))),"")

    where you have data in rows 2 to 100, expand as required - assumes you put the first formula in D2, change as required

    Both formulas require CTRL+SHIFT+ENTER
    Audere est facere

  6. #6
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: What's wrong with this Index Match/Row formula?

    Thanks daddylonglegs,

    I've modified the formula (as I have it in a seperate sheet and it seems to work perfectly) so thanks.

    However I'm trying to add the 3rd range and potentially there may be 5 in total but it's giving me an error saying I've entered too many arguements.... Do I have the syntax in the correct order?



    =IFERROR(IFERROR(INDEX('Org Structure'!G$7:G$553,SMALL(IF('Org Structure'!K$7:K$553="X",ROW('Org Structure'!K$7:K$553)-ROW('Org Structure'!K$7)+1),ROWS(A$2:A2))),INDEX('Org Structure'!N$7:N$553,SMALL(IF('Org Structure'!R$7:R$553="X",ROW('Org Structure'!R$7:R$553)-ROW('Org Structure'!R$7)+1),ROWS(A$2:A2)-COUNTIF('Org Structure'!K$7:K$553,"x"))),INDEX('Org Structure'!U$7:U$553,SMALL(IF('Org Structure'!Y$7:Y$553="X",ROW('Org Structure'!Y$7:Y$553)-ROW('Org Structure'!Y$7)+1),ROWS(A$2:A2)-COUNTIF('Org Structure'!R$7:R$553,"x")))),"")

  7. #7
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: What's wrong with this Index Match/Row formula?

    Hey daddylonglegs, any idea what I've stuffed up by adding the third range?

    =IFERROR(IFERROR(INDEX('Org Structure'!G$7:G$553,SMALL(IF('Org Structure'!K$7:K$553="X",ROW('Org Structure'!K$7:K$553)-ROW('Org Structure'!K$7)+1),ROWS(A$2:A2))),INDEX('Org Structure'!N$7:N$553,SMALL(IF('Org Structure'!R$7:R$553="X",ROW('Org Structure'!R$7:R$553)-ROW('Org Structure'!R$7)+1),ROWS(A$2:A2)-COUNTIF('Org Structure'!K$7:K$553,"x"))),INDEX('Org Structure'!U$7:U$553,SMALL(IF('Org Structure'!Y$7:Y$553="X",ROW('Org Structure'!Y$7:Y$553)-ROW('Org Structure'!Y$7)+1),ROWS(A$2:A2)-COUNTIF('Org Structure'!R$7:R$553,"x")))),"")

    Any help would be appreciated as I'm stuck!

    Thanks

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: What's wrong with this Index Match/Row formula?

    Hello Dave, you need an extra IFERROR function in there so the general structure will be like this for 3 ranges

    =IFERROR(IFERROR(IFERROR(Index1,Index2),Index3),"")

    ...and you need to keep adding the COUNTIF functions so that INDEX3 has 2 COUNTIF functions subtracted, so like this

    =IFERROR(IFERROR(IFERROR(INDEX('Org Structure'!G$7:G$553,SMALL(IF('Org Structure'!K$7:K$553="X",ROW('Org Structure'!K$7:K$553)-ROW('Org Structure'!K$7)+1),ROWS(A$2:A2))),INDEX('Org Structure'!N$7:N$553,SMALL(IF('Org Structure'!R$7:R$553="X",ROW('Org Structure'!R$7:R$553)-ROW('Org Structure'!R$7)+1),ROWS(A$2:A2)-COUNTIF('Org Structure'!K$7:K$553,"x")))),INDEX('Org Structure'!U$7:U$553,SMALL(IF('Org Structure'!Y$7:Y$553="X",ROW('Org Structure'!Y$7:Y$553)-ROW('Org Structure'!Y$7)+1),ROWS(A$2:A2)-COUNTIF('Org Structure'!R$7:R$553,"x")-COUNTIF('Org Structure'!K$7:K$553,"x")))),"")

  9. #9
    Forum Contributor
    Join Date
    05-04-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: What's wrong with this Index Match/Row formula?

    Hi daddylonglegs, I've now expanded the formula to include a forth range and it works just as needed.

    Many thanks for your help on the formula and syntax.

    Cheers

    David

+ 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] Help-> Index+Match formula pulling wrong values
    By sashafierce in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-29-2013, 07:13 PM
  2. Wrong result displaying using IFERROR-INDEX-MATCH-ROW Formula
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-16-2013, 01:03 PM
  3. [SOLVED] Index Match Question - What am I doing wrong?
    By JackieAdams in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-27-2012, 04:43 PM
  4. Index Max Match formula returning wrong value
    By bk77 in forum Excel General
    Replies: 4
    Last Post: 03-25-2009, 02:17 PM
  5. Index and Match-wrong value
    By Steved in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-13-2005, 07: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