+ Reply to Thread
Results 1 to 7 of 7

Distinct combinations using autofilter (non-contiguous range)

  1. #1
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Distinct combinations using autofilter (non-contiguous range)

    There is a raw data sheet from which i am outputting distinct (unique) values on a separate sheet for a number of columns. This is working fine for one column with code like this;

    Sheets("Raw Data").Range("A1:A5000").AdvancedFilter Action:=xlFilterCopy, _
    CopyToRange:=Sheets("Uniques").Range("D3"), Unique:=True


    However, i would like to output distinct combination from two columns that are not next to each other. Example below is columns D & F Here is the code i've tried:

    Sheets("Raw Data").Range("D1:D5000,F1:F5000").AdvancedFilter Action:=xlFilterCopy, _
    CopyToRange:=Sheets("Uniques").Range("F3:G3"), Unique:=True


    The error: Table range is not valid. Is it possible to overcome this without re-arranging the column order?

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Distinct combinations using autofilter (non-contiguous range)

    You might not understand what is going on here so let me know if you have any quesitons.

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  3. #3
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Distinct combinations using autofilter (non-contiguous range)

    Thank you for your response. Looks like a completely different approach, and you're right i don't really know what is going on!

    I am seeing an error when running this:

    "Run time error 6

    Overflow"

    The Debug highlights this line:
    For i = LBound(rng1, 1) To UBound(rng1, 1)

    Do you know how to fix this? Thank you for your help

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Distinct combinations using autofilter (non-contiguous range)

    Submit your workbook. I do not get an error.

  5. #5
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Distinct combinations using autofilter (non-contiguous range)

    I have it working now thanks - i think it was trying to paste over existing values which it didn't like.

    One minor adjustment, if you are able to help further, I would like it so that each time the macro runs it replaces anything that existed from f3:g3 downwards. Appreciate your help

  6. #6
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Distinct combinations using autofilter (non-contiguous range)

    I guess sticking this at the beginning would do the trick:

    Sheets("Uniques").Activate
    Range("F3:G3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Clear

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Distinct combinations using autofilter (non-contiguous range)

    I guess sticking this at the beginning would do the trick:
    Yes, that is one way

+ 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. Counting Distinct Entries In A Range
    By billyshears in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-09-2015, 02:05 PM
  2. [SOLVED] Using scripting dictionary to add contiguous group of items from non contiguous range
    By stnkynts in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2014, 06:12 PM
  3. [SOLVED] How to delete multiple contiguous (and/or) non-contiguous rows, in an excel table
    By jimmalk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-03-2012, 05:48 AM
  4. Replies: 0
    Last Post: 08-03-2012, 04:31 PM
  5. Contiguous "Range" from Non Contiguous Ranges
    By DonkeyOte in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-03-2011, 03:23 PM
  6. AutoFilter method of Range class failed - Yet autofilter works.
    By Carlsbergen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2009, 05:43 PM
  7. How to create chart for Combinations of distinct categories
    By jchambers00 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-27-2008, 10:33 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