restricting data entry to non-times
This little macro will do the same thing:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim s As String
If Intersect(Target, Range("G16")) Is Nothing Then
Exit Sub
End If
s = Target.NumberFormat
If InStr(1, s, ":") 0 Then
Application.EnableEvents = False
Target.Clear
Target.Select
Application.EnableEvents = True
MsgBox ("Times not allowed")
End If
End Sub
This sample checks entries in cell G16.
If the user types an entry that Excel recognizes as a time, Excel will
change the format from General to a time-style format. The macro looks for a
colon in the cell format and responds accordingly.
If text is entered rather than time:
HELLO:WORLD
the macro will allow it.
--
Gary''s Student - gsnu200730
|