VBA Clear Range in Excel explained with Examples

VBA Clear Range in Excel will Clear a specific range or entire worksheet using Clear method of Range Object. ‘Rang.Clear’ method will clear the range including the formats like border, font styles, background cell and set to default.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

VBA Clear Method Excel Range Object

Excel VBA to Clear a Range – Syntax

Here is the syntax to clear a range. You can clear the data in any range including formats using VBA ‘Range.Clear’ method.


Excel VBA to Clear a Range – Examples

The below macro will show you how to clear a range using VBA. In this example, we are clearing range “A2 to D10” using VBA.

Sub VBA_Clear_Range()
End Sub

Excel VBA to Clear a Range – Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Workbook from your start menu or type Excel in your run command
  2. Enter some data in any cells in range “A10 to D10” to test this macro.
  3. Press Alt+F11 to Open VBA Editor or you can goto Developer Table from Excel Ribbon and click on the Visual Basic Command to launch the VBA Editor
  4. Insert a Module from Insert Menu of VBA
  5. Copy the above code (for clearing the range using VBA) and Paste in the code window(VBA Editor)
  6. Save the file as Macro Enabled Workbook (i.e; .xlsm file format)
  7. Press ‘F5′ to run it or Keep Pressing ‘F8′ to debug the code line by line.

Now you can observe that the data in range “A2 to D10” is clear. You can apply any formats and background color, and try this macro. This will clear everything and set to the default.

If you want to clear only the data you can use Range.ClearContents method, to clear the comments in a range you use the Range.ClearComments method.

Range.Clear: Will clear everything including cell formats.
Range.ClearContents: Will clear only the content/data of the range, formats will remain same.
Range.ClearComments: Will clear only the comments, formats and data will remain same.


Leave A Comment

Related pages

vbscript output to text filevba excel 2007 tutorialhow to delete multiple entries in excelexcel 2010 if statementexcel save macrofind last row vbamicrosoft excel vba programmingsubstitute vba excelexcel vba if statement multiple conditionsuseful vb scriptsexcel macro columnvba workbooks.openrecord macro in excel 2007microsoft excel macro tutorialselect vbasql faqs with answershow to remove password protection in excel 2010make drop down list in excel 2007isblank functionsql interview questions for freshers pdfmerging 2 columns in excelhow do i hide a column in excellink sql to excelexcel vba tutorcombo box vba excelhow to unhide columns in excel 2007pdf excel vba programminghow to put numbers in ascending order in excelhow to remove password protection from excel 2010 workbookduplicate values in excelexcel vba worksheet namehlookup function in excel 2007macros tutorialexcel formula row heightplanner template excelvba exit loopexcel consolidate data from multiple sheetshow to unhide everything in excelweekly gantt chart templateexcel macro to hide rowsword templates agendaadd the developer tab to the ribbon in wordexcel userformssurface graph excelvba vlookupdeduplication excelconstruction estimating spreadsheet templateactivate a workbookconvert excel to csvexcel vba create formdim fso as filesystemobjectrecordset in vbahow to make radio buttons in exceladd developer tab to ribbon in word 2007how to unprotect a workbook in excel 2010 without passwordtotal no of rows and columns in excelcopy range vbavba code examples for excelddl dml dcl tcl commands in sql with examplesvba for excel tutorial for beginnerssample project plan template excelexcel project management spreadsheetwhat is hlookup in excel with examplehow do you unshare a workbookms excel formulas list with examplescosting sheet template excelremove duplicate entries excelwhat vlookup in excelexcel vba programmingmicrosoft excel adding columnsms excel chart typestask planner template excelvba excel cellexcel advanced filter formulavba macro for loop