Making a macro run after autofilter

Hiro Protagonist

New Member
Joined
Jun 6, 2007
Messages
1
I've got a workbook with a main sheet that holds all the data for a fairly complex Excel application. A couple of date entries from the main data are used in another sheet to determine the value of each entry in a graph used to show progress of certain goals.

This works fine when all the data is being considered, but I’ve recently been asked to modify it to allow people to use Autofilter on the main data so they can focus on only specific data.

I know essentially how I want to deal with the filtered data when recreating the chart, but I can’t figure out if I’m able to recognize when Autofilter has been run so I can then call the macro immediately after.

Does Autofilter raise a specific event, or do I just need to force them to run the macro after every filter is done?
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

the_original_invisible

Board Regular
Joined
May 27, 2004
Messages
199
Here's what I use:-

Code:
Private Sub Worksheet_Calculate()
Application.ScreenUpdating = False
Dim lFilt As Long, lFiltArrows As Long
Dim lFiltRow As Long
On Error Resume Next
Application.EnableEvents = False

lFiltRow = Me.AutoFilter.Range.Row
lFiltArrows = Me.AutoFilter.Filters.Count

    If Me.FilterMode = True Then
        For lFilt = 1 To lFiltArrows
            If Me.AutoFilter.Filters.Item(lFilt).On Then
                Your_Macro_Here
            End If
        Next lFilt
    End If
Application.EnableEvents = True

On Error GoTo 0
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,508
Messages
5,596,551
Members
414,077
Latest member
ammylar5

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
Top