VBA ClearFormats in Excel Explained with Examples

We can use VBA to Clear only the Formats of a specific range, cells or entire worksheet. we can use ClearFormats method of Range Object. Rang.ClearFormats method will clear only the formats of the cells or range. And the data and comments will not be deleted.



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 ClearFormats Method Excel Range Object

Excel VBA to ClearFormats a Range – Syntax

Here is the syntax to clear the formats of a range. You can clear the formats in any range using VBA Range.ClearFormats method.


Excel VBA to ClearFormats in a Range – Examples

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

Sub VBA_Clear_Formats_Range()
End Sub

Excel VBA to Clear Formats in 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. Also format some cell to test this macro.
  3. Press Alt+F11 to Open VBA Editor or you can go to 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 formats in a 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 formats in the range “A2 to D10” are cleared. You can apply any formats and background color, and try this macro. This will clear only the formats and the data, comments will be remained same.

Range.ClearFormats:Will clear only the formats of a range, remaining elements untouched.
Range.ClearContents: Will clear only the content/data of the range, formats will remain same.
Range.Clear: Will clear the data including cell formats.
Range.ClearComments: Will clear only the comments, formats and data will remain then same.


Leave A Comment

Related pages

tick box in exceltutorial vba excelhow to use iferror formula in excelexcel copy cellsxlsm to xmlvba excel column widthascending order worksheetcan you find duplicates in exceldelete rows in vbaexcel fixed rowvba excel replacemacro delete blank rowsexcel vba loop through rangesumif function in excel 2007instr syntaxexcel vba worksheet functionvba populate comboboxexcel templates databaselearning excel macroexcel insert a columnclustered column chart excel 2013password worksheetinteractive dashboard excelxml to excel converterexcel functions and syntaxtutorial on pivot tables in excel 2010vba cell formulavba excel pastecharting in excelmoving sheets in excelvb filecopyvba excel passwordmake drop down list in excel 2007excel advanced filter criteria range examplesselect range in vbaspotfire tutorialsave excel vbaexcel 2007 formulas with examplesexcel 2013 find duplicatesadodb tutorialexcel userform examplesexcel formula vbaremove hyperlinks from excelexcel programming basicsadvanced vlookupvba save pdfexcel formulas monthprogramming logic questions and answershow to use pivot chart in excel 2007ms excel 2010 developer tabexcel unlock password protected filesas macros interview questionsremove workbook passwordhow to create dashboards in excelexcel 2010 unhide sheetview developer tab in excelms excel formulas with examples pdf in hindiexcel project tracker templatedelete empty rows excelhow to create pivot chart in excel 2007password protection excel 2010powerpoint project status dashboard templateexcel macro delete rowsmacro to insert rows between datadefinition of vlookup in excelvba macro tutorialexcel templates for construction estimatingvba application.vlookupnested if function excel 2010sample pivot tablesvba copy rangeexcel cell reference vbadml in sql server