+ Reply to Thread
Results 1 to 4 of 4

Need to filter by two colors

  1. #1
    Registered User
    Join Date
    08-28-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    7

    Need to filter by two colors

    Hey There,

    I am trying to filter my data so that only the yellow and green rows show. I know how to filter by color using the following command:

    ActiveSheet.Range("$A$4:$C$11").AutoFilter Field:=1, Criteria1:=RGB(146, _
    208, 80), Operator:=xlFilterCellColor

    but I don't know how to filter by multiple colors. Maybe another way around this would be to sort first by green and then by yellow and then selecting and hiding both the red and blue cells, but I don't know how to do this either. Need to find an automatic way for this process as new rows are constantly being inserted in.

    Any help is greatly appreciated. Thank you

    al

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Need to filter by two colors

    Welcome to the Forum aljiwani!

    I the problem here is that you want to do something with AutoFilter in VBA that you can't do as an Excel user. Autofilter only allows you to select one color at a time for color filtering. However, you can write custom VBA that will scan all the rows and hide the ones that are not yellow or green. When hiding rows, the row numbers do not turn blue to indicate that filtering is on, the same as with autofilter. The user may unhide the rows but it must be done manually rather than by clearing the autofilter.

    Please Login or Register  to view this content.
    This code only looks at the color in column A, and assumes you have a header in row 1.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-28-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    7

    Re: Need to filter by two colors

    Thank you very much for your reply. I have been trying to get this to work but to no avail. Would you please be able to help me do so in the practice sheet I attached in this message. I would greatly appreciate it.

    Thank you,

    Al

    practicefile.xls

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Need to filter by two colors

    I changed the color codes to match the actual colors you are using. You will note that there is a comment in the code that this is required, but it appears that you didn't make any changes.

    Your data starts in row 5 but the macro started in row 2. It is also necessary to update that.

    Your button is configured to run Macro2 so here is the updated code:
    Please Login or Register  to view this content.

+ 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. [SOLVED] Filter by Consecutive Cell Values or Colors
    By thelegazy in forum Excel General
    Replies: 10
    Last Post: 07-26-2013, 12:20 PM
  2. Replies: 12
    Last Post: 07-08-2013, 09:33 AM
  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