Clear
Method is used to remove the contents and cell formatting of a range. This
method should not be used if you EITHER just want to remove the contents of a
range and do not want to remove the cell formatting OR just want to remove the
cell formatting and do not want to remove the contents of a range. The
following example will help to understand better.
Example:
Let
us clear the contents and format of cells B5, C5 and D5 using Clear method. Run
a macro with the following procedure:
Sub Clr()
Range("B5:D5").Clear
End Sub
Output:
Notice all the differences
happened to the cells in the cleared range
- The contents of the cells are cleared
- The border of the cells is cleared and set to template default
- The background color of the cells is set to template default i.e. White
- The font color of the cells is set to template default i.e. Black
- The font type and size of cells are changed from Arial 9 to template default i.e. Calibri 11
- The vertical alignment of the cells are changed from Middle Align to template default of Bottom Align.
- The horizontal alignment of the cells are set to template default i.e. Align Left
Please visit following posts to know about other clear methods available with Excel VBA
ClearContents - http://foryourread.blogspot.in/2014/07/excel-macro-vba-clearcontents.html
ClearFormats - http://foryourread.blogspot.in/2014/07/excel-macro-vba-clearformats.html
ClearComments - http://foryourread.blogspot.in/2014/07/excel-macro-vba-clearcomments.html
ClearHyperlinks - http://foryourread.blogspot.in/2014/07/excel-macro-vba-clearhyperlinks.html
ClearNotes - http://foryourread.blogspot.in/2014/07/excel-macro-vba-clearnotes.html
ClearOutline - http://foryourread.blogspot.in/2014/07/excel-macro-vba-clearoutline.html