+ Reply to Thread
Results 1 to 13 of 13

INDEX SMALL problem

  1. #1
    Forum Contributor
    Join Date
    07-17-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel for O365
    Posts
    197

    INDEX SMALL problem

    Hi, can someone explain why this array formula works fine...

    =IFERROR(INDEX(INDIRECT("Surveys!L6586:L7345"),SMALL(IF(INDIRECT("Surveys!L6586:L7345")<>"",ROW($E$4:$E$203)-ROW($E$4)+1,""),ROW($E$4:$E$203)-ROW($E$4)+1)),"")

    But when I change the INDEX range to "Surveys!P6586:P7345" it doesn't.

    =IFERROR(INDEX(INDIRECT("Surveys!P6586:P7345"),SMALL(IF(INDIRECT("Surveys!P6586:P7345")<>"",ROW($E$4:$E$203)-ROW($E$4)+1,""),ROW($E$4:$E$203)-ROW($E$4)+1)),"")

    It is meant to return the non-blank cells from the INDIRECT range in cells D3:D203. Both columns L & P have the same content, just in a different order so I'm at a loss at to why it'll work for one and not the other.

    Any help greatly appreciated.

    Jason

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,080

    Re: INDEX SMALL problem

    UPDATE: Forget this, just saw your data is in a different order, this wont work.

    What does this produce?

    in any cell type
    =SUMPRODUCT(--(L6586:L7345=P6586:P7345))

    It should be 760
    If its not then your data is NOT the same.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Contributor
    Join Date
    07-17-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel for O365
    Posts
    197

    Re: INDEX SMALL problem

    Bump.

    Still not managed to resolve!

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

    Re: INDEX SMALL problem

    Hello Jason,

    You say you are putting the first formula in D3:D203, where are you putting the second one? Your formula actually returns an array so unless you are "array entering" in a range (rather than array entry in one cell and copying down) then it could make a difference depending on where you enter the formula.

    I recommend you change the end part to ROWS function - the formula will then return a single value and can be array entered in a single cell and copied down.

    Ideally the ROWS function should match the first cell, so assuming you put the second formula in E3 first try this version:

    =IFERROR(INDEX(INDIRECT("Surveys!P6586:P7345"),SMALL(IF(INDIRECT("Surveys!P6586:P7345")<>"",ROW($E$4:$E$203)-ROW($E$4)+1,""),ROWS(E$3:E3))),"")

    confirm with CTRL+SHIFT+ENTER and copy down the column
    Audere est facere

  5. #5
    Forum Contributor
    Join Date
    07-17-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel for O365
    Posts
    197

    Re: INDEX SMALL problem

    Hi daddylonglegs, thanks for the response and apologies for the confusion. There is only one array formula in the range D3:D203, I'm just trying to tweek it to gather the contents of a different column.

    When entering the formula I'm selecting the range D3:D203, then using the formula bar to enter the above, then CTRL + SHIFT + ENTER.

    The purpose is to take the contents of one column in another sheet (Surveys!P6586:P7345), and show only the non-blank cells in the range D3:D203. In all honesty, I'm familar with INDEX but I'm not sure how the SMALL and ROW aspect of the formula works. At the time I put the question to this forum and somebody kindly supplied this solution.

    I'll have a go at using your modification and let you know the outcome. Should I enter the revised formula in cell D3 and array enter, drag down?

    Many thanks,

    Jason

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

    Re: INDEX SMALL problem

    In that case I'm not really sure why your revised formula doesn't work.

    What do you get with that formula, do you get blanks or errors or just not all the data you expected?

  7. #7
    Forum Contributor
    Join Date
    07-17-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel for O365
    Posts
    197

    Re: INDEX SMALL problem

    Yeah I thought as much! Can't understand why it won't work.

    It returns just blanks in the range D3:D203 when the formula is set to column P. When it's column L, I get the non-blank cells only in order of appearance.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: INDEX SMALL problem

    Hi.

    Not sure I understand your formulas.

    Apart from the issue pointed out by daddylonglegs re the construction you are using for the k parameter of the SMALL function, there is also the fact that:

    Surveys!P6586:P7345

    is a range comprising 760 rows.

    whereas:

    ROW($E$4:$E$203)-ROW($E$4)+1

    generates an array comprising just 200 rows.

    Hence any non-blank entries beyond P6785 will simply not be considered. In fact, every formula will return a blank since every formula will result in an error by virtue of your array being passed to SMALL being filled with #N/A errors as a result of this issue.

    These two ranges need to be of the same dimension, e.g.:

    =IFERROR(INDEX(INDIRECT("Surveys!P6586:P7345"),SMALL(IF(INDIRECT("Surveys!P6586:P7345")<>"",ROW(INDIRECT("Surveys!P6586:P7345"))-ROW(INDIRECT("Surveys!P6586"))+1,""),ROWS($1:1))),"")

    though can I also ask why you are using INDIRECT in this expression, especially since you are simply hard-coding the sheet name in the formula, and not e.g. referencing it dynamically from some cell?

    Regards
    Last edited by XOR LX; 02-11-2015 at 08:24 AM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  9. #9
    Forum Contributor
    Join Date
    07-17-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel for O365
    Posts
    197

    Re: INDEX SMALL problem

    Hi XOR LX and thanks for your input.

    I'm using INDIRECT as the workbook containing this formula is a template that then has another sheet (Surveys) moved in from a different workbook. I'm hard-coding rather than putting the source in a seperate cell just for tidiness.

    Okay, that makes sense what you're saying about the two ranges needing to be the same dimension. It will have worked for Column L as all of the non-blank cells will invariably be toward the top, whereas column P has the same data scattered throughout.

    As I said, I'm just not sure on how the SMALL function works to be able to interpret what the overall formula is trying to do.

    When trying your revised formula, it's returning the first non-blank cell throughout the whole range of D3:D203. Progress though - Any idea what is causing that?

    Many thanks,

    Jason

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: INDEX SMALL problem

    I think it's about time you uploaded an actual workbook!

    Regards

  11. #11
    Forum Contributor
    Join Date
    07-17-2013
    Location
    Birmingham, England
    MS-Off Ver
    Excel for O365
    Posts
    197

    Re: INDEX SMALL problem

    Would be happy to but the file size is 6.55mb, this forum, as I'm sure you're aware only allows 1mb files to be attached. I could email it if that's acceptable?

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: INDEX SMALL problem

    Actually it doesn't have to be the actual file. Are you not able to create a reduced example which at least exhibits the same issue?

    Regards

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

    Re: INDEX SMALL problem

    Quote Originally Posted by jwillis07 View Post
    When trying your revised formula, it's returning the first non-blank cell throughout the whole range of D3:D203. Progress though - Any idea what is causing that?
    I assume you are trying to array enter that single formula in the whole range. XOR LX's suggested formula would go in D3, array entered and copied down.

    If you want to put it in as a single formula try this version:

    =IFERROR(INDEX(INDIRECT("Surveys!P6586:P7345"),SMALL(IF(INDIRECT("Surveys!P6586:P7345")<>"",ROW(INDIRECT("Surveys!P6586:P7345"))-ROW(INDIRECT("Surveys!P6586"))+1,""),ROW(INDIRECT("Surveys!P6586:P7345"))-ROW(INDIRECT("Surveys!P6586"))+1)),"")

+ 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. Problem with INDEX/SMALL in formula
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2015, 01:52 PM
  2. Replies: 7
    Last Post: 10-10-2014, 05:40 PM
  3. [SOLVED] Problem with function INDEX, SMALL AND IF
    By dejussy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-08-2014, 10:36 PM
  4. Replies: 6
    Last Post: 10-22-2013, 01:48 PM
  5. Problem with Index and Small functions to lookup and display multiple cells
    By oneblondebrow in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-22-2013, 11:41 AM

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