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

 

Instructions:
  1. Open an excel workbook
  2. Enter some data in Sheet1 at A1:C10
  3. Press Alt+F11 to open VBA Editor
  4. Insert a Module for Insert Menu
  5. Copy the above code and Paste in the code window
  6. Save the file as macro enabled workbook
  7. Press F5 to run it

 

 

 

Share This Post

11 comments

Leave a Reply

Your email address will not be published.