+ Reply to Thread
Results 1 to 25 of 25

Dynamically extracting a list of unique values from non adjacdent column ranges

  1. #1
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi,

    I have found this formula online

    =IFERROR(INDEX($M$25:$M$27, MATCH(0,COUNTIF($A$31:A31, $M$25:$M$27), 0)),"")

    which is working great for my scope.

    However, I do not know how to make it work for NON ADJACENT column ranges.

    I have attached my sample file. The formula is in 05 FRIDAY sheet, cells A32,A33,A34, and the data are in M25:M27,O25:O27,Q25:Q27,S25:S27,U25:U27,W25:W27
    As a side note: I copied this formula in 01 MONDAY and it does not calculate anything, the cell only shows the formula. Why?

    Any help would be greatly appreciated.

    Thank you and best regards,
    Alberto
    Attached Files Attached Files

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,305

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    The golden rule Do not use ######### merged cells.

    Capture.JPG

  3. #3
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi Torachan,

    I cannot understand your answer (or, maybe, your answer was not intended to me). The formula works fine. I just need to know how to select NON-ADJACENT cells in the criteria. How can I add cell ranges to $M$25:$M$27?
    With regards to the side note, I solved by simply changing the cell format from Text to General.

    Thanks and best regards,
    Alberto

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,305

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    follow the link below, the chap finally got the message


  5. #5
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi Torachan,

    thanks again but I still cannot understand what your reply has to do with my thread.
    I have no problem with the formula. It works fine. I am simply asking how to make an array with non adjacent cells.
    I have INDEX which has this array $M$25:$M$27; now, I need to know how to extend this array using non-adjacent cells. I do not know what syntax to use and I cannot find any example online; people seem to assume that ranges exist only as contiguous cells.
    Also, I have no idea where you got your error from. I have no error in my sheet.

    Thanks and best regards,
    Alberto

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

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi,

    Is there a possibility that the columns in between each of the non-contiguous ranges you specify could contain values which are also valid Job Numbers?

    I only ask as interrogating a single two-dimensional array is generally far more straightforward than interrogating one comprising non-contiguous ranges.

    Regards
    Click * below if this answer helped

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

  7. #7
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi XOR LX,

    thanks for your interest.
    No, actually the way I built the file requires that in between the columns containing the job numbers we have the hours worked.
    I tried adding cell ranges using spaces in the array, and the syntax seemed to be correct, but in actual fact the formula DOES NOT return anything, just blanks (no error messages), and the values shift by one cell down.

    I cannot understand what torachan is trying to tell me. He/she is insisting with this merged cells thing which, in actual fact, is not affecting me (I am not receiving any error).
    The point is, the formula works fine only if I use it with the first column.
    If I want to include also other columns, well, blanks happen

    Here is the updated formula which is causing the cell to show blank:

    =IFERROR(INDEX($M$25:$M$27 $O25:$O$27 $Q$25:$Q$27 $S$25:$S$27 $U$25:$U$27 $W$25:$W$27, MATCH(0,COUNTIF($A$31:A31,$M$25:$M$27 $O25:$O$27 $Q$25:$Q$27 $S$25:$S$27 $U$25:$U$27 $W$25:$W$27), 0)),"")

    Thanks,
    Alberto

  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: Dynamically extracting a list of unique values from non adjacdent column ranges

    Ok, I understand, but is there any feature shared by the Job Numbers which at the same time will never be shared by the hours figures?

    For example, it would seem to me that the Job Numbers are all text entries (despite their appearance, you have them all formatted as 'number stored as text'), whereas the hours figures are all formatted as proper numerics. If you confirm that this is always the case then this criterion could be used to extract your list via interrogation of the single, contiguous range M25:X27.

    As I mentioned, it would be far preferable to use some such condition to interrogate a single, contiguous range than to have to work with multiple, non-contiguous ranges. I'm not saying that the latter is impossible (it isn't); it's just disproportionately more complex!

    Regards

  9. #9
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi XOR LX,

    well, I am not sure whether I properly understood your reply but Job numbers are all in the form 19980 - five numerical digits.

    Does this help?

    Thanks,
    Alberto

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,162

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

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

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Ah, so the data in the book you posted was just mocked up (job numbers are 4 digits)?

    In any case, that might suffice as a criterion, thanks. Can you just confirm the number format for those job numbers in your real workbook (right-click, Format Cells will tell you)? Even if they're in actuality proper numerics, I imagine we could distinguish them from the hours, assuming that there will never be a 5-figure hours entry, correct?

    Regards

  12. #12
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi AliGW,

    I just took for granted that cross posting was bad habit but, indeed, it seems the opposite.
    The question has been also asked here: https://www.mrexcel.com/board/thread...anges.1129469/

    Thank you and kind regards,
    Alberto

  13. #13
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi XOR LX,

    yes those numbers were just a mockup.

    The real figures are 5 digits numerics stored as text. Hours will never be stored as 5-digits but only as default numbers.

    Thank you and best regards,
    Alberto

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

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Ok, thanks. Let's assume, then, that the only text entries within the range M25:X27 are your desired extractions.

    Try the following array formula** in A32:

    =IFERROR(INDIRECT(TEXT(MIN(IF(ISTEXT(M$25:X$27),IF(COUNTIF(A$31:A31,M$25:X$27)=0,10^5*ROW(M$25:X$27)+COLUMN(M$25:X$27)))),"R0C00000"),0),"")

    and copy down until you start to get blanks for the results.

    N.B. If you have any null strings ("") within the range M25:X27, e.g. as a result of formulas within those cells, then these will equally be considered 'text' and so be returned by the formula. If this is the case let me know and I will post a modified version.

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  15. #15
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,894

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    FYI - If you enter XOR LX's formula as array in Office 365, it will cause error mentioned by torachan (i.e. you can't enter array formula over merged range)
    In those case, just enter the formula as is, new array behavior will take over and will evaluate to single value.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

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

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    N.B. I forgot that you might not be using an English language-version of Excel, in which case it's possible that, as well as translating the function names, you may require an alternative version of the part "R0C00000". "R" and "C" represent "row" and "column" here, though I have a strong feeling they are locale-dependent.

    Regards

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

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Quote Originally Posted by CK76 View Post
    FYI - If you enter XOR LX's formula as array in Office 365, it will cause error mentioned by torachan (i.e. you can't enter array formula over merged range)
    In those case, just enter the formula as is, new array behavior will take over and will evaluate to single value.
    Good point. I tested in 365 though unmerged the cells (out of habit) prior to entering the array formula.

    Cheers

  18. #18
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Quote Originally Posted by Giulio Severini View Post
    Hi XOR LX,

    well, I am not sure whether I properly understood your reply but Job numbers are all in the form 19980 - five numerical digits.

    Does this help?

    Thanks,
    Alberto
    Yes, Please try at A32

    =AGGREGATE(15,6,$M$25:$W$27/ISTEXT($M$25:$W$27)/(--$M$25:$W$27>MAX(A$31:A31)),1)
    Attached Files Attached Files

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

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Bo_Ry's solution is in any case much better: shorter and, more importantly, non-volatile.

    Regards

  20. #20
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi guys,

    once again I have to thank you for your great contribution!
    I have tried Bo_Ry's solution and it works perfectly.
    XOR LX, I have tried your solution also - with and without blanks in the range - but the results are not sorted in ascending order (from smaller to bigger) but random.
    I have a question, now. Bo_Ry's solution works for all kind of content format or only for 5-digits numerical content?
    I have other cells where the jobs are in the 4-digits format.

    Also, just to understand: what is the problem with the merged cells, as pointed out by torachan?
    The formula I was using was returning the right results although the reference was in a merged cell.
    So, what am I missing in his answer?

    Many thanks to all, I will be posting the solution to the other forum as well.

    Alberto
    Last edited by Giulio Severini; 04-02-2020 at 02:39 PM.

  21. #21
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi Alberto

    The formula work on any number stored as text and with less than 15 digits as it is a Number precision limit.


    Merge cells won't accept Ctrl+Shift+Enter.
    Some array formula require Ctrl+Shift+Enter Eg: Small(IF , Transpose
    Some like Aggregate doesn't need

    But Office 365 has dynamic array, no more Ctrl+Shift+Enter. so no problem.
    But for best, Please avoid merge cells.


    Regard

  22. #22
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi Bo_Roy,

    I have just a small problem with your formula: if there is no value it returns #NUM!.

    I tried this

    =IF(AND(ISBLANK($M$25:$X$27),"", AGGREGATE(15,6,$M$25:$W$27/ISTEXT($M$25:$W$27)/(--$M$25:$W$27>MAX(A$31:A31)),1)))

    but Excel returns an error.

    Any suggestion?

    Many thanks and best regards,
    Alberto

  23. #23
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Please try
    =IFerror(AGGREGATE(15,6,$M$25:$W$27/ISTEXT($M$25:$W$27)/(--$M$25:$W$27>MAX(A$31:A31)),1),"")

  24. #24
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi Bo_Roy,

    that's perfect!
    I do not really know how to thank you!

    Best regards,
    Alberto

  25. #25
    Registered User
    Join Date
    02-19-2020
    Location
    Malta
    MS-Off Ver
    Office 365
    Posts
    51

    Re: Dynamically extracting a list of unique values from non adjacdent column ranges

    Hi Bo_Roy,

    that's perfect!
    I do not really know how to thank you!

    Best regards,
    Alberto

+ 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] Dynamically Extracting Unique Values from Filtered List (Visible Rows Only)
    By AliGW in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-08-2018, 10:37 AM
  2. Replies: 2
    Last Post: 06-16-2016, 08:09 PM
  3. Replies: 0
    Last Post: 07-21-2015, 04:44 PM
  4. [SOLVED] Extracting unique values from a list
    By vienvy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-08-2015, 12:49 AM
  5. [SOLVED] Extracting Unique Values From a List...using formula
    By szejtan99 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-24-2014, 07:42 PM
  6. Copy a list with unique values dynamically
    By tabfri in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-19-2013, 01:51 AM
  7. Extracting unique values from live list
    By J.W. Aldridge in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-19-2006, 10:10 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