Forum Discussion

CHileman's avatar
CHileman
Copper Contributor
Jul 01, 2022
Solved

Help with Macro Hygiene Please

It's not that the macros run slowly, or that Excel crashes, but it just takes a while to get excel selected when coming from another program or webpage.    I tend to have to cut and paste a good de...
  • NikolinoDE's avatar
    Jul 02, 2022

    CHileman 

    Try setting up your macro like this, it should actually be faster.

     

    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    
    'Here insert your code
    
    With Application
        .Calculation = xlAutomatic
        .ScreenUpdating = True
        .EnableEvents = True
    End With

     

    Example according to your code specifications.

     

    'Example with your first code
    
    Sub Unhide_All()
    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
      ActiveSheet.ShowAllData
    End If
    
    Columns.EntireColumn.Hidden = False
    Rows.EntireRow.Hidden = False
    With Application
        .Calculation = xlAutomatic
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    End Sub

     

     

    Hope I was able to help you :).

     

    NikolinoDE

    I know I don't know anything (Socrates)

Resources