The code below creates an overflow error on this line:
Code: Select all
If Not Application.CountIf(Target, "=") = Target.Cells.Count Then
What other test can I use to avoid the event running if the target cells are not selected?
TX
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.CountIf(Target, "=") = Target.Cells.Count Then
If Not Intersect(Union([B18], [B19], [B20], [B25], [B26], [B27], [B32], [B33], [B34]), Target) Is Nothing Then
Target.Value = CleanPhoneNumber(CStr(Target.Value))
End If
End If
Application.EnableEvents = True
End Sub