+ Reply to Thread
Results 1 to 18 of 18

Filter by all colors

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Filter by all colors

    I'm using Excel 2010, and have a spreadsheet with columns containing Red, Blue, yellow, and green cells, plus some with no color. If I apply an autofilter, I can filter for any individual color, or for no colors. But how do I do it if I want all colored cells, or to filter out the non-colored?

    Thanks in advance,
    John

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Filter by all colors

    Specific column? All columns?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Filter by all colors

    Color is not really data to Excel. You could use another columns that controls (or is indicative of) the cell color, and then filter on that.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    XeRo Solus,
    Assume just one column.

    SHG,
    Sure, I can do it by creating a helper column. I wondered, though, if there was another way.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Filter by all colors

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    Cool! Had to change the <> to =, becuase I want to show the colors. Also had to turn off Screenupdating (my worksheet had 12K rows, of which 3 had colored cells).
    How would I change it to use the column my active cell is in?

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    Came up with a workable solution, but I'm certainly open to better ideas:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Filter by all colors

    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    MUCH better job of coding than mine. Thanks! I thought there might be a time difference because I used 'for each' and you didn't, but my clunky version and your streamlined version both do the whole range (12K rows, 3 with colored cells) in 3.03 seconds. I don't know if it could be made faster, but this version certainly works for me. Thanks for all your help!

  10. #10
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Filter by all colors

    Hello,
    sorry if I intrude in the thread.
    The macro Xero Solus does not work for me, where did I go wrong?
    Thanks for the control.
    max_max
    -----------------------------------------------------------------
    Ciao,
    scusate se mi intromette nel thread.
    La macro di Xero Solus non mi funziona, dove ho sbagliato?
    Grazie del controllo.
    max_max

    color 30_08_13.xlsm

  11. #11
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    Max,
    What error are you seeing?

    I'm currently putting it through it's paces, and have spotted a problem. My reported run time earlier was with that being the only workbook open. Now I have 5 workbooks open, and when i try to run the macro it just keeps running. I tried using "With Activesheet", but that doesn't seem to have any affect. I have to hit escape to get out of it.

  12. #12
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Filter by all colors

    Hello,
    I hope that is understandable English, I translate with google translator.
    The second macro:

    Sub UnfilterColorless ()
    UsedRange.EntireRow.Hidden = False
    end Sub

    does not return rows, maybe it does not work on excel 2007?
    max_max
    -------------------------------------------------------------------------------
    Ciao,
    spero che il inglese sia comprensibile, traduco con google traduttore.
    La seconda macro:

    Sub UnfilterColorless()
    UsedRange.EntireRow.Hidden = False
    End Sub

    non fa ritornare le righe, forse non funziona su excel 2007?
    max_max

  13. #13
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    I had to make a change to mine, maybe you do, too.
    Please Login or Register  to view this content.
    Also, update on the problem I'm seeing: I closed all the workbooks, reopened just a couple, tried again, and it worked fine. So, not sure what the issue was.
    Last edited by jomili; 08-30-2013 at 09:33 AM.

  14. #14
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Filter by all colors

    O.k. the macro works,
    Now there are 2 macros for a macro that filters all the colored cells as you change?

    Sub FilterColorless () 'non-colored cells
    Dim cel As Range

    For Each cel In Range ("A2: A120" & Range ("A" & Rows.Count). End (xlUp). Row)
    If cel.Interior.ColorIndex <> -4142 Then
    cel.EntireRow.Hidden = True
    end If
    Next cel
    end Sub

    max_max

    ---------------------------------------------------------------------------------------

    O.k. la macro funziona,
    Ora ci sono 2 macro, per una macro che filtri tutte le celle colorate come si modifica?

    Sub FilterColorless() 'cells non color
    Dim cel As Range

    For Each cel In Range("A2:A120" & Range("A" & Rows.Count).End(xlUp).Row)
    If cel.Interior.ColorIndex <> -4142 Then
    cel.EntireRow.Hidden = True
    End If
    Next cel
    End Sub

    max_max

  15. #15
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    There's a filter and an unfilter.

    The one you posted, named "Sub FilterColorless () 'non-colored cells", is unnecessary if using Excel 2010, because Excel can already filter for non-colored cells. As well, a macro to filter by a specific color is unnecessary because Excel already has that capability.

    This one filters for all of the colored cells regardless of color in a column, which Excel doesn't currently do natively.
    Please Login or Register  to view this content.
    This one unhides all the rows hidden by the macro above.
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Filter by all colors

    Hello,
    in a forum to excel in Italy I found these macros. They are faster to filter colored cells.
    max_max
    ------------------------------------------------------------------------------------------------
    Ciao,
    in un forum per excel in Italia ho trovato queste macro. Sono più veloci a filtrare le celle colorate.
    max_max

    color_B 30_08_13.xlsm

  17. #17
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Filter by all colors

    They're actually not any faster on my test data. They only reason they appear faster is that they're only filtering 120 rows with only a few uncolored cells, whereas I'm filtering 12000 rows with only 3 colored cells.

  18. #18
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: Filter by all colors

    Now is 12000 rows, it is a little slower.
    max_max
    ------------------------------------------
    Ora è per 12000 righe, è un pò più lento.
    max_max

    color_C 30_08_13.xlsm

+ 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. Need to filter by two colors
    By aljiwani in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2013, 09:38 PM
  2. [SOLVED] Filter by Consecutive Cell Values or Colors
    By thelegazy in forum Excel General
    Replies: 10
    Last Post: 07-26-2013, 12:20 PM
  3. Replies: 3
    Last Post: 08-08-2008, 06:12 AM
  4. changing filter arrow colors
    By Tonka_Joe_Kiwi in forum Excel General
    Replies: 0
    Last Post: 11-19-2005, 12:30 AM
  5. EasyFilter 2.1 Beta : filter on Colors and bold cells
    By Ron de Bruin in forum Excel General
    Replies: 0
    Last Post: 03-24-2005, 12:06 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