I know there's a property to add in the beginning of the macro so that all the selections and deselection happen in the background and are not shown on the sheet. I think I had to disable some property at the beginning of the macro and enable it at the end. Does anyone remember what it was?
+3
A:
This is what you're looking for:
Application.ScreenUpdating = False
Just remember to call this
Application.ScreenUpdating = True
at the end (and make sure you have error handling. If it fails and you do not set it back to true, the application will appear to be frozen forever.
Gabriel McAdams
2010-08-24 16:14:47
These two lines will speed up certain macros by a factor of 10 or more.
Codo
2010-08-24 16:43:48
When changing settings like that it's usually a good idea to have an error handler that restores ScreenUpdating back to true. That way if your function crashes you're not stuck with wonky settings.
Michael
2010-08-24 16:58:31
+2
A:
Best practice would be to avoid working with selections altogether.
Other than to initially determine which cell/object the user wants to carry out an action on, you just refer directly to the objects you need to.
To give a very simple example, instead of
Range("G18").Select
ActiveCell.Value = "123"
You use
Range("G18").Value = "123"
e100
2010-08-25 13:14:52