Forum Discussion

Tyrell Williams's avatar
Tyrell Williams
Copper Contributor
Dec 01, 2017

How to code an event macro to to trigger a recorded macro when data in the workbook is refreshed

Hello,

I recorded a macro to use an advanced filter, sort and remove duplicates from another sheet in my workbook. I want to trigger the macro I recorded each time the data in my book is refreshed. What would the code for such a task look like? Any help would be appreciated.

This is the code for the macro I recorded.

Sub Backlog_Filt_And_CleanQ()
'
' Backlog_Filt_And_Clean Macro
' Filters data from extracted and removes duplicates
'
' Keyboard Shortcut: Ctrl+Shift+B
'
    Sheets("Extracted Data").Columns("A:J").AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Range("'Q (Filtered from Extracted)'!Criteria"), CopyToRange _
        :=Range("'Q (Filtered from Extracted)'!Extract"), Unique:=False
    Columns("A:J").Select
    ActiveSheet.Range("$A$1:$J$850").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6) _
        , Header:=xlYes
End Sub

No RepliesBe the first to reply

Resources