+ Reply to Thread
Results 1 to 6 of 6

Unique values using VBA

  1. #1
    Registered User
    Join Date
    09-22-2009
    Location
    Midland, Michigan
    MS-Off Ver
    Excel 2007
    Posts
    8

    Unique values using VBA

    Hello,

    I'm trying to write VBA code to generate a list of unique values. The source values (with duplicates) are stored in E3:E25, and I want the unique values to be placed in G3:G25. Here's what I'm trying:
    Please Login or Register  to view this content.
    But this doesn't seem to work. Either one of the values is duplicated in G3:G25, or I get a run-time error ("The extract range has a missing or illegal field name."). Help?!

    Thanks,
    --David
    Last edited by david.aukerman; 06-11-2010 at 02:05 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Unique values using VBA

    Maybe this:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Unique values using VBA

    Also, note you need a header for advanced filter otherwise the top value will be considered as one, so causing an apparent duplicate.

  4. #4
    Registered User
    Join Date
    09-22-2009
    Location
    Midland, Michigan
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Unique values using VBA

    Quote Originally Posted by JBeaucaire View Post
    Maybe this:

    Please Login or Register  to view this content.
    That doesn't quite do it, either. The run-time error doesn't happen any more, which is good. But the first value is still repeated in the results list. Attached is a sample spreadsheet to show what I mean.

    Thanks,
    --David
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-22-2009
    Location
    Midland, Michigan
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Unique values using VBA

    Quote Originally Posted by StephenR View Post
    Also, note you need a header for advanced filter otherwise the top value will be considered as one, so causing an apparent duplicate.
    Oh... I see. So the AdvancedFilter needs to start one row higher than I wanted it to start...

    Please Login or Register  to view this content.
    ...seems to work. Many thanks, all!

    --David

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Unique values using VBA

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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