Posted By

BDOGG32 on 04/01/15


Tagged

speed excel vba


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BDOGG32


SpeedOn and SpeedOff


 / Published in: Visual Basic
 

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

  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  

You need to login to post a comment.