Share via


Clear Method [Excel 2003 VBA Language Reference]

Clear method as it applies to the ChartArea, Legend, and Range objects.

Clears the entire object.

expression.Clear

expression Required. An expression that returns one of the above objects.

Clear method as it applies to the CellFormat object.

Clears the criterias set in the FindFormat and ReplaceFormat properties.

expression.Clear

expression Required. An expression that returns a CellFormat object.

Clear method as it applies to the XPath object.

Clears all XPath schema information for the mapped range. Clear affects the entire range mapped to this XPath object.

expression.Clear

expression Required. An expression that returns a XPath object.

Remarks

This method does not clear the data from the cells mapped to the specified XPath. Use the Clear method of the Range object to clear the data from the cells.

If the specified XPath is mapped in an XML list, then the schema mapping is removed, but the list is not deleted from the worksheet.

If the mapped range is a single-cell then the single-cell is removed and the data remains.

This method will produce an error if any of the following conditions are true:

  • The range spans multiple columns in the grid.
  • Part of the range spans already mapped cells and the rest spans unmapped cells.
  • Part of the range spans one mapping, and another part of the range spans a different mapping or different XPath from the same mapping.

Example

This example clears the formulas and formatting in cells A1:G37 on Sheet1.

Worksheets("Sheet1").Range("A1:G37").Clear

This example clears the chart area (the chart data and formatting) of Chart1.

Charts("Chart1").ChartArea.Clear

Applies to | CellFormat Object | ChartArea Object | Legend Object | Range Collection | XPath Object

See Also | ClearContents Method | ClearFormats Method