How to: Clear Styles from Ranges in Workbooks

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

  • Application-level projects

Microsoft Office version

  • Excel 2003

  • Excel 2007

For more information, see Features Available by Application and Project Type.

You can clear styles that have been added to a NamedRange control or a native Excel range object by applying the Normal style to the range.

Clearing Styles from a NamedRange Control

This example assumes that you have a NamedRange control named rangeStyles on the worksheet. The following code must be placed in a sheet class, not in the ThisWorkbook class.

To clear the styles in a NamedRange control

  • Apply the Normal style to the range. This code must be placed in a sheet class, not in the ThisWorkbook class.

    Me.rangeStyles.Style = "Normal"
    
    this.rangeStyles.Style = "Normal";
    

Clearing Styles from a Native Excel Object

To clear the styles in a workbook range

  • Apply the Normal style to the range.

    Dim rng As Excel.Range = Me.Application.Range("A1")
    rng.Style = "Normal"
    
    Excel.Range rng = this.Application.get_Range("A1", missing);
    rng.Style = "Normal";
    

See Also

Tasks

How to: Apply Styles to Ranges in Workbooks

Concepts

Working with Ranges

NamedRange Control

The Variable missing and Optional Parameters in Office Solutions