+ Reply to Thread
Results 1 to 15 of 15

Formula for next unique value

  1. #1
    Registered User
    Join Date
    01-22-2008
    Posts
    38

    Formula for next unique value

    I am trying to create a formula that would referance a column of numbers and return the next unique number in the list. Example:

    Column A
    1
    1
    1
    2
    2
    3
    3
    3

    In column B I would like a formula in each row that would return

    Column B
    1
    2
    3

    Any helo would be appreciated.
    Last edited by NBVC; 03-30-2009 at 04:55 PM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    The easiest way to do that would be with Advanced Filtering, Unique references only. If you want to use formulas to create a unique list
    Please Login or Register  to view this content.
    which when dragged down, will copy each new/unique number as it's encountered. Do either of these options work for you?

    ChemistB

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    For that second method, to bring the values together in Column C, you'd use this formula copied down
    Please Login or Register  to view this content.
    where row 40 is the last row of your data. Adjust the row if you aren't starting in Row 1.

    ChemistB

  4. #4
    Registered User
    Join Date
    01-22-2008
    Posts
    38
    ChemistB,

    It seems that the second formula isn't working for me. Is the =if(=if.....correct?

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Oops, no
    Please Login or Register  to view this content.
    ChemistB

  6. #6
    Registered User
    Join Date
    01-22-2008
    Posts
    38
    Thank you for the assistance. I am still having trouble for Column C where the return values should be a clean list (no blank cells) of the unique values in column B....

    Help?

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Here's an example file. See if this helps.

    ChemistB
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-22-2008
    Posts
    38

    Re: Formula for next unique value

    ChemistB,

    Thanks for your help a while back. I need to revist this question. Can I use this same formula to retrieve Unique TEXT date insteatd of NUMERIC as I previously was requesting. It works beautifully for NUMERIC, but I can't get it to work for TEXT (names for example)..

  9. #9
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: Formula for next unique value

    Assuming that A2:A10 contains the data, try...

    B2, confirmed with CONTROL+SHIFT+ENTER:

    =SUM(IF(FREQUENCY(IF(A2:A10<>"",MATCH("~"&A2:A10,A2:A10&"",0)),ROW(A2:A10)-ROW(A2)+1),1))

    C2, confirmed with CONTROL+SHIFT+ENTER, and copied down:

    =IF(ROWS(C$2:C2)<=$B$2,INDEX($A$2:$A$10,SMALL(IF(FREQUENCY(IF($A$2:$A$10<>"",MATCH("~"&$A$2:$A$10,$A$2:$A$10&"",0)),ROW($A$2:$A$10)-ROW($A$2)+1),ROW($A$2:$A$10)-ROW($A$2)+1),ROWS(C$2:C2))),"")

    Hope this helps!

  10. #10
    Registered User
    Join Date
    01-22-2008
    Posts
    38

    Re: Formula for next unique value

    Works awesome.....1 last thing...Is there anyway to build into the calc an ascending sort of the data. Essentially, i am trying to use this list to build a drop-down menu of the unique values and would love to have it in order....
    Thanks so much

  11. #11
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: Formula for next unique value

    Try...

    B2:

    =SUM(IF(FREQUENCY(IF(A2:A10<>"",MATCH(A2:A10,A2:A10,0)),ROW(A2:A10)-ROW(A2)+1),1))

    C2, confirmed with CONTROL+SHIFT+ENTER, and copied down:

    =IF(ROWS(C$2:C2)<=$B$2,INDEX($A$2:$A$10,MATCH(SMALL(IF(ISNA(MATCH($A$2:$A$10,$C$1:C1,0)),MMULT(($A$2:$A$10>TRANSPOSE($A$2:$A$10))+0,ROW($A$2:$A$10)^0)),1),MMULT(($A$2:$A$10>TRANSPOSE($A$2:$A$10))+0,ROW($A$2:$A$10)^0),0)),"")

    Note that MMULT will return #VALUE! if the output of cells exceeds 5,460. If this is the case, download and install the free add-in Morefunc, and use MMULT.EXT instead.

    Hope this helps!

  12. #12
    Registered User
    Join Date
    01-22-2008
    Posts
    38

    Re: Formula for next unique value

    Thanks. I keep getting a #NAME error in when doing the formula. I have attached an example....help...
    Attached Files Attached Files

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

    Re: Formula for next unique value

    The formula you copied from Domenic's post has a space within the last ROW() function.. you need to eliminate that space after copying it over and then confirm with CSE keys.
    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.

  14. #14
    Registered User
    Join Date
    01-22-2008
    Posts
    38

    Re: Formula for next unique value

    Worked like a charm.

    Thank you so much!!!

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

    Re: Formula for next unique value

    Please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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