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?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,037
Members
448,543
Latest member
MartinLarkin

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