+ Reply to Thread
Results 1 to 4 of 4

AdvancedFilter and Blank Cells

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    AdvancedFilter and Blank Cells

    Hello, All.

    I am working with AdvancedFilter to pull a list of unique values from a Table (ListObject) in excel. The table column in question has many blank cells in it by design.

    When I use the code
    Please Login or Register  to view this content.
    on that column I get nothing back.

    If I fill all the blank cells with N/A for example (which I dont really want to do) I get back what I would expect to see.

    Does AdvancedFilter have an aversion to blank cells? None of the MS documentation i read on the method indicated that it does.

    Thank you.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: AdvancedFilter and Blank Cells

    Hi,
    Usually the advanced filter has no issued with blank cells, at least I've never noticed such thing. Do you have an example?
    In case you need this unique list in vba for further processing I'd recommend to use a dictionary rather than the advanced filter.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: AdvancedFilter and Blank Cells

    Quote Originally Posted by tehneXus View Post
    Hi,
    Usually the advanced filter has no issued with blank cells, at least I've never noticed such thing. Do you have an example?
    In case you need this unique list in vba for further processing I'd recommend to use a dictionary rather than the advanced filter.
    Sure, here is the dataset. I cut out all the supporting data but, this is the column in the table (called Categories) that I am trying to do an advanced filter on. Again, in it's current form and with the code above, nothing is pasted into B1:BX. However, if I add N/A or some other data to the blank cells, I get back all the unique results including N/A...which is not really what I am looking to do. I will have to write some other code to exclude N/A.

    With the dictionary, are you suggesting to read the data into a dictionary, then sort? Is that programatically quicker than advancedFilter?
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: AdvancedFilter and Blank Cells

    Hi,

    The advanced Filter needs a heading in the 1st row selected, unfortunately by referring to a column in a table (listobj) only the data is passed to the range object in vba, a workaround:
    Please Login or Register  to view this content.
    Note that you cannot use the adjacent column as target range, this will result in a application defined error as you cannot have 2 identical headings in a table.

    dictionary solution:
    Please Login or Register  to view this content.
    Filter vs dictionary:
    - When sheet is protected you cannot use filter
    - Formatting is kept using filter, dic provides values only
    - dic is 3 times faster (based on processing your test data 1000 times)

+ 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