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

conditional statements in vbscriptfor loop in macro excelsql ddl commands with examplesconvert xlsx to xmldocmd.runsql deleteexcel msgbox yes nomacro to delete rows in exceliferror excel formulainput box vbavb copy fileexcel workbook password removersqlfunctionsexcel vba elseifdelete a row in excel vbapivot table in sql server 2008excel multiple conditionsproject management template in exceldescending order dates exampleexcel count filled cellspivot tables tutorialsunhide a column in excelapplication wait vbaado odbc connection stringsas code tutorialremove doubles in exceladjust column width excelvba cell referencehow to use pivot table excel 2010how to hide columns in excel 2007how to delete duplicates in excel 2010excel 2010 password remover macrointroduction to sas ppthlookup function in excel with exampleprompt vbavba filehow to unmerge cellsexcel 2007 show developer tabhow to save excel file in xlsx formatwhat if statements in excel 2010advanced excel 2007 formulas with examplesvba xml tutorialdml downloadexcel macro workbooks openinputbox vbaexcel vba on cell changevlookup excel syntaxworkbooks vbaadvanced sorting in excelexcel remove blank rows3d graph in excelinsert multiple rows excel 2010learning macros in excel 2007adodb.recordset openwhat is concatenate exceltask management spreadsheet excellearn vlookup in excel 2013autofilter macrohow do you do a tick on excelexcel estimate templatemsgbox access vbamicrosoft excel chart wizardsql server ddl commandshow to merge rows in excelmultiselectionms excel name managerinsert rows excel shortcutcomment in vbarange properties vbaclear comboboxexcel shortcut insert columnmicrosoft excel countif functionaccess vba for loopdeveloping dashboardshow to convert column to row in excelrange of cells in excel formuladdl commands in sql