Using With and End With When Referring to an Object
In the previous code, several lines all refer to the same chart object. Rather than reference
this object on every line of code, you could specify the chart object once in a
With state-
ment. In each subsequent line, you could leave off the name of the chart and begin the line
with a period. You would end the block of code with an
End With statement. This is faster
to write than typing the complete object name multiple times, and it executes faster because
Excel only has to figure out what
WS.ChartObjects(“Chart1”) means once. The following
code uses the With syntax while setting five properties: ...