+ Reply to Thread
Results 1 to 13 of 13

countif values is unique in a range

  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    91

    countif values is unique in a range

    hi!

    tried to solve this and didn't get very far...

    anyway, should be a simple problem for you excel experts

    i have one column of text strings (column S). there are unique and duplicate values in this column.

    what i need in column T is a formula i can drag down that only counts if the immediate row in column S is a unique value in the range S:S.

    for example:
    if S2 is unique in the range S:S, return 1
    if S3 is unique in the range S:S, return 1
    if S4 is unique in the range S:S, return 1
    if S5 is a duplicate in the range S:S, return 0

    i thought of using =MATCH(S2,S:S,0) and dragged down, which does tell me which rows are unique... but i don't know how to continue further


    thank you so much in advanced for the help

  2. #2
    Registered User
    Join Date
    09-01-2011
    Location
    SK
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: countif values is unique in a range

    =if(countif($s$2:$s$5,s2)>1,1,0)

  3. #3
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: countif values is unique in a range

    hi hluk, try:
    =IF(COUNTIF($S$2:S2,S2)>1,0,1)

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  4. #4
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: countif values is unique in a range

    wait....your condition changes at S5...Why?
    otherwise a IF(COUNTIF(... sould work fine
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    drag down

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  5. #5
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: countif values is unique in a range

    LOL...seems we all hit the thread right close together

  6. #6
    Registered User
    Join Date
    09-01-2011
    Location
    SK
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: countif values is unique in a range

    Yeah, Range=S:S is cleaner. Good call.

  7. #7
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: countif values is unique in a range

    it looks neater, and applies to a variable range easier, but a defined range is probably faster...the problem is, we have no idea what the actual range is, so I just used the whole column

  8. #8
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: countif values is unique in a range

    and benishiryo's will return the first occurrence of the value(1), then puts the others as repeats(0), which may be what the OP actually wants..

  9. #9
    Registered User
    Join Date
    07-09-2008
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    91

    Re: countif values is unique in a range

    Quote Originally Posted by dredwolf View Post
    wait....your condition changes at S5...Why?
    otherwise a IF(COUNTIF(... sould work fine
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Hope this helps
    hey thanks!

    i tried this... but i am not getting the result i need

    here is the existing result:
    2 0
    2 0
    3 0
    3 0
    4 0
    4 0
    4 0
    4 0
    4 0
    10 1
    11 1
    12 1
    13 1
    14 1
    15 1

    here is what i hope the result to be:
    2 1
    2 0
    3 1
    3 0
    4 1
    4 0
    4 0
    4 0
    4 0
    10 1
    11 1
    12 1
    13 1
    14 1
    15 1


    sorry i didn't explain it properly... is it possible to modify it so that it counts each value once... then if has been counted once, the duplicates will get a 0?

  10. #10
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: countif values is unique in a range

    put this in T2 and drag-fill down:

    Please Login or Register  to view this content.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  11. #11
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: countif values is unique in a range

    use benishiryo's formula, as my last post stated, his will return the numbers you are looking for I believe

    Edit-
    forgot, Drag or Copy it down

    Edit 2
    icestationzbra's should work just as well too
    Last edited by dredwolf; 12-14-2012 at 11:24 PM.

  12. #12
    Registered User
    Join Date
    07-09-2008
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    91

    Re: countif values is unique in a range

    woot!

    working now. thanks!

  13. #13
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: countif values is unique in a range

    check icestationzbra's (post #10) as well, a different approach that may work better

+ 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