How do I detect if a certain table column has a certain filter activated?

Klash Ville

Board Regular
Joined
Sep 19, 2017
Messages
83
Hello everyone,

I have a rather complex question... which is the following:

I have a table column header called "Column1" which has the following filter activated through VBA:

Code:
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=.ListColumns("Column1").Index, Criteria1:=RGB(255, 199, 206),
Operator:=xlFilterCellColor

This filters for all cells whose color result from the following RGB code combination which was inicially formed through Conditional Formatting. Anyway, I cannot figure out the right way to build an if to detect either if that filter is being activated, or not.

Code:
Basicly, I want this:

If Column1.autofilter = RGB(255, 199, 206) Then
MsgBox "Yes"
Else
MsgBox "No"
End If
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
The thing is I don't need a for... and I don't need to know if filters are ON or OFF.

I simply wish to know how to to know if a certain column has a certain spefici filter activated like the following code I provided above

Code:
If ActiveSheet.ListObjects("Table2").Range.AutoFilter.Criteria1 = RGB(255, 199, 206) Then
        MsgBox "Filter mode is on"
    Else
        MsgBox "Filter mode is off"
    End If
End If

This is the closest I got to success, but, it complains about an object not being present... I don't know what else to do... help pls
 
Last edited:
Upvote 0
The thing is I don't need a for... and I don't need to know if filters are ON or OFF.

I simply wish to know how to to know if a certain column has a certain spefici filter activated like the following code I provided above

Code:
If ActiveSheet.ListObjects("Table2").Range.AutoFilter.Criteria1 = RGB(255, 199, 206) Then
        MsgBox "Filter mode is on"
    Else
        MsgBox "Filter mode is off"
    End If
End If

This is the closest I got to success, but, it complains about an object not being present... I don't know what else to do... help pls

Someone?
 
Upvote 0
Hi ,

I am not sure , but see if this works :
Code:
If ActiveSheet.ListObjects("Table2").AutoFilter.Range.Cells(2, 2).Value [COLOR=#333333][I]= RGB(255, 199, 206)[/I][/COLOR]
 
Upvote 0
Hi ,

I am not sure , but see if this works :
Code:
If ActiveSheet.ListObjects("Table2").AutoFilter.Range.Cells(2, 2).Value [COLOR=#333333][I]= RGB(255, 199, 206)[/I][/COLOR]

Awwww that was so close x.x
Sadly, when applied in an if with a Yes and No MsgBox, it's always stating that the filter is never applied, even when it is =/
 
Upvote 0
Hi ,

Can you provide a link to your file ?

Sadly I cannot, but the info I provided is just enough to get the entire picture.

In 1 table column, I got some cells with the RBG color that was originated from Conditional Formatting, and then I filter those same cells with the following code:

Code:
           With ActiveSheet.ListObjects("Table2")
                .Range.AutoFilter Field:=.ListColumns("Column1").Index, Criteria1:=RGB(255, 199, 206), Operator:=xlFilterCellColor
           End With

And this is your code applied with my filter code above:

Code:
        If ActiveSheet.ListObjects("Table2").AutoFilter.Range.Cells(2, 2).value = RGB(255, 199, 206) Then
            MsgBox "Yes"
        Else
            MsgBox "No"
            With ActiveSheet.ListObjects("Table2")
                .Range.AutoFilter Field:=.ListColumns("Column1").Index, Criteria1:=RGB(255, 199, 206), Operator:=xlFilterCellColor
            End With
        End If

I also just modified the cell coordinates to the correct one: (2, 8), but the result is the same... strange =/
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top