Monday, August 10, 2020

VBA Excel How to Clear All data in Excel sheet Range Except Formulas

Sub ClearConstantData(rng As Range)
    Dim cl As Range
    For Each cl In rng.Cells
        If Not cl.HasFormula Then
            If cl.Value <> "" Or Not (IsEmpty(cl)) Then
                cl.ClearContents
            End If
        End If
    Next
End Sub

No comments:

Post a Comment

Hot Topics