SpeedOn and SpeedOff


/ Published in: Visual Basic
Save to your folder(s)

Code to turn certain feature off and on for faster running of code in Excel


Copy this code and paste it in your HTML
  1. Option Explicit
  2.  
  3. Public glb_origCalculationMode As Integer
  4.  
  5. Sub SpeedOn(Optional StatusBarMsgAs String = "Running macro...")
  6. glb_origCalculationMode= Application.Calculation
  7. With Application
  8. .Calculation = xlCalculationManual
  9. .ScreenUpdating= False
  10. .EnableEvents= False
  11. .DisplayAlerts= False
  12. .Cursor = xlWait
  13. .StatusBar= StatusBarMsg
  14. .EnableCancelKey= xlErrorHandler
  15. End With
  16. End Sub
  17.  
  18. Sub SpeedOff()
  19. With Application
  20. .Calculation = glb_origCalculationMode
  21. .ScreenUpdating= True
  22. .EnableEvents= True
  23. .DisplayAlerts= True
  24. .CalculateBeforeSave= True
  25. .Cursor = xlDefault
  26. .StatusBar= False
  27. .EnableCancelKey= xlInterrupt
  28. End With
  29. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.