VBA – ClearFormats – Remove Formatting For Each Cell In Range
In this Article
When formatting a cell in excel using VBA you may want to make sure you are starting with a clean slate, or removing any possible formatting already on a cell. You can do this by using ClearFormats.
Clear Formats From a Range of Cells
This will clear formats for a range of cells.
Sub ClearFormats() range("a1:c1").clearformats end sub
If you are working with a large range, you could also loop through each cell to prevent Excel from freezing.
Loop through Cells and Clear Formats
The following example will eliminate the formatting for each cell in a range using a loop:
Public Sub RemoveFormatting() Dim c As Range For Each c In Range("A:A") c.ClearFormats Next c End Sub
VBA Coding Made Easy
Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!