Friday, July 25, 2014

Excel Macro VBA - ClearOutline Method

ClearOutline method is used to clear outline of a range. It actually excludes the range from the outline group. Let us take a look at the following example:

There is an outline from A2 to C4 in Sheet 1.

Sheet 1 – Collapsed



Sheet 1 – Expanded























If you would like to clear outline of a range, say, from A3 to C3 in Sheet 1, run a macro with following code:

Sub ClrOutline()

    Range("A3:C3").ClearOutline

End Sub

If the cleared range is in between an outline group, the group will then be split into two groups - 1 group above and 1 group below the outline range cleared. The result will look like this:

Sheet 1 - Expanded ( after outline for A3:C3 is cleared )





















Sheet 1 - Collapsed ( after outline for A3:C3 is cleared )























On the other hand, if the cleared range is at the top or bottom of the outline group, it will just be excluded and the uncleared range will remain as a single outline. Run a macro with following code:

Sub ClrOutline()

    Range("A2:C3").ClearOutline

End Sub

After clearing outline from the top 

























Run a macro with following code:

Sub ClrOutline()

    Range("A4:C4").ClearOutline

End Sub

After clearing outline from the bottom

No comments:

Post a Comment