+ Reply to Thread
Results 1 to 40 of 40

Filter uniques and ignore empty cells

  1. #1
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Filter uniques and ignore empty cells

    Hi folks!

    As most of you know I'm not a programmer.

    I saw some code that uses advanced filter to extract unique entries to another location so I tried adding to it. Here's what I've come up with:

    Please Login or Register  to view this content.
    If the data in column A is not in a contiguous range the filter procedure considers empty cells a unique entry and includes the empty cell in the extraction range.

    My question is: how to get this to ignore empty cells?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Filter uniques and ignore empty cells

    Hi,

    I know this might not be the answer you are looking for. But you could go around it like this

    Please Login or Register  to view this content.
    or you could create a loop?

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Filter uniques and ignore empty cells

    I am not a programmer too but as this codes reminds something to me a simple approach could be this.

    Please Login or Register  to view this content.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    That seems to work OK.

    I'm wondering if this would be a good/practical alternative to using formulas to extract the uniques.

    Thanks!

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    When I try this I get run time error 438, object doesn't support this property or method.

    I was looking for an event macro to do this to make it dynamic as an efficient alternative to using formulas to extract the uniques.

    Thanks!

  6. #6
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Filter uniques and ignore empty cells

    which code are you using Tony?

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by fredlo2010 View Post
    which code are you using Tony?
    Yours worked and Fotis' generated the error.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Filter uniques and ignore empty cells

    Alternative
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    I'll play around with that tomorrow when I have more time.

    Thanks!

  10. #10
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Filter uniques and ignore empty cells

    Another way with scripting dictionary:
    Please Login or Register  to view this content.
    or, alternatively (slower):
    Please Login or Register  to view this content.

    All best,

    berlan
    Last edited by berlan; 12-30-2013 at 12:14 AM.

  11. #11
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Filter uniques and ignore empty cells

    ..Tony Valko
    which code are you using Tony?

    Yours worked and Fotis' generated the error.
    As i told i am not a programmer and i am sure that all the others codes are much better than mine. I just replied here because the code for unique list using Advanced Filter in another thread- that you told about-was mine.

    But i know very well that my suggestion gives no error!

    http://screencast.com/t/kYb3XR67

    @ fredlo2010


    Thanks for the rep and your kind comment!
    Attached Files Attached Files

  12. #12
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    Fotis' version will require Excel 2007 or later version - it seems Tony Valko may use Excel 2002 version also, where it will not work.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    Yes, I use Excel 2002 as my default version so I tried Fotis' code in that version.

    Just tried it in Excel 2007 and it worked but it included the column header as data and sorted it into the real data.

  14. #14
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    For 2002 version (and later) Fotis' code may be:
    Please Login or Register  to view this content.

  15. #15
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Filter uniques and ignore empty cells

    ..Just tried it in Excel 2007 and it worked but it included the column header as data and sorted it into the real data.
    No this is not corect. I attached a sample workbook that shows that does not exists such a problem and also a video that also shows that there is not such a problem.

    You insist just to say that this does not works for some reason. Unfortunately i can not proove that i am not an elephant!

    Good luck.

  16. #16
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    @Fotis

    Your code will not work in 2003 or previous version because Sort object does not exist so error 438 is raised. I do not understand comment about elephants?

  17. #17
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Izandol View Post
    @Fotis

    Your code will not work in 2003 or previous version because Sort object does not exist so error 438 is raised. I do not understand comment about elephants?
    I replied to this comment of Tony Valko.

    ..Just tried it in Excel 2007 and it worked but it included the column header as data and sorted it into the real data.
    I have reason to don't accept your explanations for Excel 2003.

    My English are not so good so i'll try to explain my comment for Elephant...

    If someone tell me: "You are an Elephant and not a human". How can i proove to him that i am not?

    I'll show a picture of me and of many other people. If he insists that i am an Elephant, then i have no other way to proove that i am not!

    I hope to be more clear now.

  18. #18
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Fotis1991 View Post

    You insist just to say that this does not works for some reason.
    Because it doesn't work in my versions of Excel.

    Here's a sample file done in Excel 2007. Note how the column header is sorted into the data.

    No need to get upset.

  19. #19
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Fotis1991 View Post
    I have reason to don't accept your explanations for Excel 2003.
    What is reason?

    Code in your posted workbook is not same code as in your first reply, which uses different ranges and has changed the line:
    Please Login or Register  to view this content.
    for:
    Please Login or Register  to view this content.
    Last edited by Fotis1991; 12-30-2013 at 11:37 AM.

  20. #20
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Filter uniques and ignore empty cells

    Apologize!! My English....!

    I wanted to say that

    I have no reason to don't accept your explanations for Excel 2003.

  21. #21
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Tony Valko View Post
    Because it doesn't work in my versions of Excel.

    Here's a sample file done in Excel 2007. Note how the column header is sorted into the data.

    No need to get upset.
    You forgot the attachment.

    It's not the problem if i am or not upset.And i am not. I am just too busyat this time but also i'd like to clear this issue. The problem is-and you know better than me as you are in the forums longer time than me-when the op just says:"This Does not works".

  22. #22
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Fotis1991 View Post
    Apologize!! My English....!

    I wanted to say that

    I have no reason to don't accept your explanations for Excel 2003.
    All is clear now.

  23. #23
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Fotis1991 View Post
    You forgot the attachment.

    I am just too busyat this time...
    Yeah, me too! That's why I forgot to post the file.

    Here it is:

    Fotis(1).xlsm

  24. #24
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Filter uniques and ignore empty cells

    To attach a sample sheet in our forum.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    In post#11 i uploaded a sample workbook. There were 2 modules with 2-a little-differents macros. The ClickMe button was connected with the macro called "Sub ÌáêñïåíôïëÞ5()"--YEs it's Greek..!" and works great.

    In your example sheet you use the macro called "MACRO1" and this gives you wrong results.

    Use the correct code and everything will be ok:
    Please Login or Register  to view this content.
    and works fine.
    Attached Files Attached Files

  25. #25
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Fotis1991 View Post

    In your example sheet you use the macro called "MACRO1" and this gives you wrong results.
    MACRO1 is the code you posted in reply #3.

    Use the correct code and everything will be ok:
    Please Login or Register  to view this content.
    and works fine.
    Using the code above in Excel 2007 I get duplicated results.


    Data Range
    A
    B
    C
    D
    1
    Header
    -----
    -----
    2
    1
    1
    3
    1
    1
    4
    2
    5
    a
    6
    2
    x
    7
    1
    8
    x
    9
    10
    2
    11
    12
    x
    13
    a

  26. #26
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Filter uniques and ignore empty cells

    How about
    Please Login or Register  to view this content.
    Last edited by jindon; 12-30-2013 at 04:07 PM.

  27. #27
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Filter uniques and ignore empty cells

    Try this if you want it sorted as well:

    Please Login or Register  to view this content.

  28. #28
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    @ jindon...

    I finally found some time to try your suggestion in reply #8.

    Worked as expected and was relatively "fast" on large amounts of data.

    On the initial calculation it took about 3 seconds to extract 101 unique items from a range of 10,000 rows.

    Thanks!
    Last edited by Tony Valko; 12-30-2013 at 04:28 PM.

  29. #29
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Filter uniques and ignore empty cells

    Glad it worked.

    But does it work on Mac?

  30. #30
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    I'll try the other suggestions when I get enough time to test them. I'll let everyone know how they work.

  31. #31
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    Dictionary is not available on Mac but there are many hash table-type classes that may be used in place.

  32. #32
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Filter uniques and ignore empty cells

    Most of the poster knows Mac doesn't support ActiveX object and perhaps no Evaluate method that I used in post #8 that Tony refers to.

    So, in that case, my code in #26 should work.

  33. #33
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    If most poster knows this why ask the question if it will work on Mac?

  34. #34
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Filter uniques and ignore empty cells

    Who are you talking to?

    I didn't post any code using Dictionary here, but not sure if Evaluate method works on Mac.

  35. #35
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    Oh I am sorry - I did not see berlan posted code with Dictionary and not you. I understand and apologise.

  36. #36
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Filter uniques and ignore empty cells

    Evaluate will work on Mac, by the way.

  37. #37
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Filter uniques and ignore empty cells

    Quote Originally Posted by Izandol View Post
    Evaluate will work on Mac, by the way.
    OK, and thanks for that.

  38. #38
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    @ berlan

    Just tested your code in reply #10 that uses the scripting dictionary.

    This worked as expected and is very fast!

    It took about 1 second to extract 101 unique entries from 10,000 rows of data.

    Thanks!

  39. #39
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Filter uniques and ignore empty cells

    If Dictionary is considered, this will be faster
    Please Login or Register  to view this content.

  40. #40
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Filter uniques and ignore empty cells

    @ jindon

    Yes, that version is also very fast. Less than 1 second to extract the 101 unique entries from 10,000 rows of data.

    Thanks!

+ 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. Excel 2007 : Ignore empty cells? How?
    By PA0l0 in forum Excel General
    Replies: 3
    Last Post: 06-02-2011, 07:29 PM
  2. How to get a formula to ignore empty cells
    By scudder12 in forum Excel General
    Replies: 1
    Last Post: 10-02-2010, 06:18 PM
  3. Trying to ignore empty cells in excel 07
    By G33kman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-14-2009, 03:15 PM
  4. Can a formula ignore empty cells?
    By Melissa in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-31-2006, 01:30 PM
  5. [SOLVED] Trendline to ignore empty cells
    By Kara in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-07-2005, 01:05 PM

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