Results 1 to 6 of 6

Thread: Finding distinct values in a column

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    29

    Finding distinct values in a column

    If I had a column of say zip codes, lets say thousands, and I have a lot of repeats. Is there a built in function in Excel that lets me find all the distinct zip codes and then outputs it into an array or string? I am pretty sure I can think of a way of doing this by just using VBA, but I was just wondering if there was some built in stuff to make it simplier.

  2. #2
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: Finding distinct values in a column

    I think the "subtotals" option is the only one that can serve u r purpose a little bit at least...

    thanx & regards
    Anu
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Finding distinct values in a column

    You could look at a pivot table.
    Select the data
    Menu>Data>Pivot tables
    Click yes
    Click yes (to the range)
    Click layout, drag n drop the field into data and row
    (data should change to count - if not double click it and change it to count)
    Click finish

    It should give you a sheet with the list of values (unique) and a count of those values.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4
    Lively Member JustinLabenne's Avatar
    Join Date
    Jul 2005
    Location
    Ohio
    Posts
    64

    Re: Finding distinct values in a column

    You could also try using the Advanced Filter option. It allows you to copy the uniques records to a new location.
    Justin Labenne
    www.jlxl.net

  5. #5
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Finding distinct values in a column

    The Advanced Filter option in coding and into an array...

    VB Code:
    1. Dim arrVals()
    2.   Range("A1:A" & Range("A1").End(xlDown).Row).AdvancedFilter xlFilterCopy, , Range("B1"), True
    3.   arrVals = Range("C1:C" & Range("C1").End(xlDown).Row).Value

    Be warned tho the resulting array is defined as a two dimensional array with the first dimension holding the row position and the second dimension holding the column like..

    arrVals(1,1) the first cell
    arrVals(2,1) the second cell
    arrvals(n,1) the nth cell
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2005
    Posts
    29

    Re: Finding distinct values in a column

    I'm not sure but I could swear that the advanced filter option worked when you did it manually, that is it would copy all the values that suited a particular filter, but then when I tried to do it in a macro it had a lot of problems.

    I know for a fact that Excel has issues with you searching for a certain field and then moving that field and then doing a find next...it just can't handle that well. I ended up copying that field, doing a find next, and then deleting it later. If you delete it in between, like I said, it craps out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width