With End With
- 01:14
Using With End With to make Excel VBA code more efficient.
Downloads
No associated resources to download.
Transcript
With end with Code provides a more efficient method of applying multiple operations to an object.
You'll more than likely be familiar with, with end with if you've ever looked through the code.
After using the macro recorder to modify the property of a range of cells, the two procedures in the Visual Basic Editor achieve the same objective.
They apply the aerial font to the text in the selection.
They make the font bold of the text in the selection, and they resize the font to 12.
Finally, they underline the text in the selection you'll note in the second procedure instead of writing multiple lines of long code.
Using with selection font means that each of the subsequent lines of code are treated as if they read selection, do font, and then the subsequent lines of code within the with end with loop.
When using, with end with must be used to close the loop.