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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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