Clear Cells in Excel Range Worksheet using VBA
Most of the times we complimentary the data from a cells or a range and approaching-enter to get some calculations. For examples we may have some template to enter data and calculate the tax. We may sore to complete this for all the employees of an dispensation. In this skirmish we dependence to Clear data Excel from a Range in Worksheet using VBA in the since entering the data for each employee
Clear Cells Range data in Excel Worksheet using VBA – An Example
The following examples will show you how clear the data of Cells, Range or entire worksheet using Clear and Clear Contents Methods.
Clearing a Cells/Range using Clear Method
This method will clear the range of cells including Formats:
Sub ClearCells() Range("A1:C10").Clear End Sub
Clearing Only Data of a Range using ClearContents Method
This method will clear only clear the content or data of the range not formats (Formats remain same)
Sub ClearCellsOnlyData() Range("A1:C10").ClearContents End Sub
Clearing Entire Worksheet using Clear Method
This method will clear entire worksheet including formats.
Sub ClearEntireSheet() Sheets("SheetName").Cells.Clear End Sub
Clearing Only Data from Worksheet using ClearContents Method
This method will clear only data of worksheet, not formats.
Sub ClearEntireSheetOnlyData() Sheets("SheetName").Cells.ClearContents End Sub
- Open an excel workbook
- Enter some data in Sheet1 at A1:C10
- Press Alt+F11 to open VBA Editor
- Insert a Module for Insert Menu
- Copy the above code and Paste in the code window
- Save the file as macro enabled workbook
- Press F5 to run it