Excel code runs very slowly

09Tina

New Member
Joined
Dec 16, 2019
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hi, I have a code that excel runs very slowly (about 3 or 4 minutes) and i don't know what the problem is. I tried with option to put calculation on manually but it's not helpful at all, I also tried put it into a code, it didn't worked. Please help!
My code:
Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)

 Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
 Dim WS As Worksheet
Set WS = Sheets("Sheet1")
With WS
    .Unprotect Password:="0000"
    .UsedRange.Locked = True
    .UsedRange.SpecialCells(xlCellTypeBlanks).Locked = False
    .Protect Password:="0000"
End With

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Exit Sub

End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Maybe try this
VBA Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim WS As Worksheet
    Set WS = Sheets("Sheet1")
    With WS
        .Unprotect Password:="0000"
        .UsedRange.Locked = True
        .UsedRange.SpecialCells(xlCellTypeBlanks).Locked = False
        .Protect Password:="0000"
    End With
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0
If you select cell A1 on sheet1 & use Ctrl End, where do you end up?
 
Upvote 0
I would also suggest deleting all the rows below the last row data may well speed other things up as well & reduce the size of the file.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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