With - End With

If you are going to perform several different actions on the same object use the With ....... End With.
This construct enables you to perform multiple operations on a single object.
After an object is assigned to a variable VBA can access it more quickly than it can a lengthy reference that has to be resolved.
The fewer the dots, the faster the processing time.
Another way to improve the speed is to use the With - End construct.


With Selection.Font 
   .Name = "Arial"
   .Size = 12
End With

Important

Using With-End can speed things up but it does make the code harder to debug as you can't quickly drag expressions into the Watch Window.


© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext