Is it posible in VBA to find out which column is filtered ?

leogetz97

New Member
Joined
Feb 21, 2003
Messages
10
Hi,

I have a sheet with an autofilter applied.

Is it possible to write to a cell which filters are applied?

I already found out how to read the criterian :

Dim f as filter

For Each f In Me.AutoFilter.Filters
If f.On Then
MsgBox (f.Criteria1)
End If
next

BUT, this is not suitable. I only need the know the Column name , not the creterian, of each column in this autofilter if its filtered.

Thanks!

Leo Getz
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Is VBA needed?

Leo,

I'm not sure what you want to do. But if you want to know what columns are filtered while looking at the report, then look at the tiny tiny arrow next to the auto-filered column name. If it is Blue then there is a filtered applied in that column.

I must admit, because it is small you can overlook the color. I was the same way until someone pointed it out.

Hope that hellped
-DBD
 
Upvote 0
Try something like this:

Code:
Sub GetColumns()
   Dim Sht As Worksheet
   Dim i As Long
   
   Set Sht = ActiveSheet
   
   With Sht.AutoFilter
      For i = 1 To .Filters.Count
         If .Filters(i).On Then
            MsgBox .Range(1, i).Column
         End If
      Next i
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,195
Members
453,021
Latest member
pingpong7117

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