I have to macro one for changing the text in rang to uppercase and the other one for clear rang content. This the first one
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Target, Range("B9:B28")) _
Is Nothing) Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
.Value = UCase(.Value)
Application.EnableEvents = True
End If
End With
End If
End Sub
It work fine and when I enter a value it changes it to uppercase, But when I run this macro to clear range content
Sub clearCellContentsKeepFormatting()
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Are you sure about this?", vbYesNo + vbQuestion, "Clear All Proudcts")
If Answer = vbYes Then
Range("B9", "B28").ClearContents
Range("C9", "C28").ClearContents
Else
Exit Sub
End If
End Sub
I get
Runtime Error 13 type mismatch
And when I press debug button it marks this line
.Value = UCase(.Value)
So, How can I fix that?
target.count=1or disable events in your clearcell procedure. - SJR