September 8, 2019

Automatically Clear Contents of Worksheet without Clearing Formulas

How to automatically clear contents of a worksheet without deleting the formulas using VBA. Watch the video below:

Here’s the complete VBA code:
Sub removeMyConstants()

Dim myConstants As Range
Dim cel As Range

Set myConstants = Sheet1.Range(“A1:F4”).SpecialCells(xlCellTypeConstants)
On Error Resume Next

For Each cel In Range(“A1:F4”)
If cel.Value = 0 Then

cel.NumberFormat = “#;#;”

End If


End Sub