Results 1 to 7 of 7

Clearing all data filters by macro

Threaded View

Andrew-Mark Clearing all data filters by... 07-30-2011, 10:49 AM
JBeaucaire Re: Clearing all data filters... 07-30-2011, 12:35 PM
talhawahab Re: Clearing all data filters... 11-17-2011, 09:58 PM
Andrew-Mark Re: Clearing all data filters... 08-01-2011, 04:23 AM
johnjohns Re: Clearing all data filters... 08-01-2011, 04:34 AM
Andrew-Mark Re: Clearing all data filters... 08-01-2011, 05:25 AM
Andrew-Mark Re: Clearing all data filters... 08-01-2011, 06:59 AM
  1. #1
    Forum Contributor
    Join Date
    05-20-2008
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    176

    Clearing all data filters by macro

    I have the following code which works fine except that sometimes I have been filtering the lists of data on some pages so when the code copies through to my overview sheet it misses some of the data.

    What I am after is a way to automatically clear all filters from all pages (inc overview) when I select the overview sheet.

    Option Explicit
    
    Private Sub Worksheet_Activate()
    
    Dim ws As Worksheet, LR As Long
    Application.ScreenUpdating = False
    Range("A2:M" & Rows.Count).ClearContents
    
    
    
    
    For Each ws In Worksheets
        If ws.Name <> Me.Name Then
                    LR = ws.Range("A" & Rows.Count).End(xlUp).Row
            If LR > 1 Then
                ws.Range("A2:M" & LR).Copy
                Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            
            End If
        End If
    Next ws
    
    
    Columns("A:K").Select
        Application.CutCopyMode = False
        ActiveWorkbook.Worksheets("Overview").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Overview").Sort.SortFields.Add Key:=Range("A1"), _
            SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("Overview").Sort
            .SetRange Range("A2:M" & Rows.Count)
            .Header = xlNo
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    
    Cells.Columns.AutoFit
    Columns("G:H").Select
        Selection.EntireColumn.Hidden = True
    
    Application.ScreenUpdating = True
    End Sub
    Any help will be much appreciated as ever.

    Andrew
    Last edited by Andrew-Mark; 08-01-2011 at 07:03 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1