Consulting

Results 1 to 3 of 3

Thread: Speed up VBA filtering

  1. #1
    VBAX Newbie
    Joined
    May 2017
    Posts
    1
    Location

    Speed up VBA filtering

    Hello,

    I have some VBA I have written which filters two tables (one above the other) and similar code that removes the filter. There are 1100 and 6000 records in the tables respectively. The filters are now taking 17 seconds to filter/unfilter and given the use case that is quite a nuisance. Would love it if any of the VBA gurus here could provide some tips or examples of how I could speed it up. NB the tables are updated when they are filtered.

    Sub rowFilterByRoW()'
    ' rowFilterByRoW Macro
    '
        With Sheets("RoW Data")
        
        Dim criteria As String
        criteria = "*" & Range("rowDataRoWFilter").Value & "*"
        Application.ScreenUpdating = False
     
        .Range("RoWData[ROWID]").AutoFilter Field:=1, Criteria1:=criteria
        .Range("RoWAddresses[ROWID]").AutoFilter Field:=1, Criteria1:=criteria
        Application.ScreenUpdating = True
        End With
    
    
        Application.EnableEvents = True
    
    
    End Sub
    Sub rowClearFilter()
    '
    ' rowClearFilter Macro
    '
    
    
    '
        ActiveSheet.ListObjects("RoWData").Range.AutoFilter Field:=1
        ActiveSheet.ListObjects("RoWAddresses").Range.AutoFilter Field:=1
        
    End Sub

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I am afraid the code tells us nothing, we need to see the workbook to even attempt any improvements.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Start the routine with
    Applicaton.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    and end with
    Applicaton.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

Tags for this Thread

Posting Permissions

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