This works:
'******************************* BEGIN VARIABLE DEFINITIONS
Dim x
'******************************* END VARIABALE DEFINITIONS
Application.StatusBar = "Resetting Fields..."
Application.ScreenUpdating = False
ActiveSheet.Range("A1:F50").Select
For Each x In Selection.Cells
If x.Locked = False Then
If x.MergeCells Then
x.MergeArea.Name = "MergedCells"
Range("MergedCells").ClearContents
Else
x.ClearContents
End If
End If
Next
Application.ScreenUpdating = True
Application.StatusBar = "Ready"
End Sub
However, I want to put a value of 0 in the field if it's formatted as currency. The code below does nothing but clear the merged cell:
'******************************* BEGIN VARIABLE DEFINITIONS
Dim x
'******************************* END VARIABALE DEFINITIONS
Application.StatusBar = "Resetting Fields..."
Application.ScreenUpdating = False
ActiveSheet.Range("A1:F50").Select
For Each x In Selection.Cells
If x.Locked = False Then
If x.MergeCells Then
x.MergeArea.Name = "MergedCells"
Range("MergedCells").ClearContents
Else
Select Case x.NumberFormat
Case "General"
x.ClearContents
Case "mm/dd/yy;@"
x.ClearContents
Case "#,##0.00"
x.Value = "0"
End Select
End If
End If
Next
Application.ScreenUpdating = True
Application.StatusBar = "Ready"
End Sub
Bookmarks