Een familie van Microsoft-spreadsheetsoftware met hulpprogramma's voor het analyseren, in kaart brengen en communiceren van gegevens.
Probeer het zo eens, met timeserial:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim uur As String, minuut As String
If Application.Intersect(Target, Range("b9:is739")) Is Nothing Or Target.Cells.Count > 1 Or Target.Value = "" And IsNumeric(Target.Value) Then Exit Sub
With Target
Select Case Len(.Value)
Case 3 To 4
If Right(.Value, 2) > 59 Then MsgBox ("Een uur heeft maar 60 minuten"): GoTo fout
If Left(.Value, IIf(Len(.Value) = 4, 2, 1)) > 23 Then MsgBox ("Een dag heeft maar 24 uur"): GoTo fout
uur = Left(.Value, IIf(Len(.Value) = 4, 2, 1)): minuut = Right(.Value, 2)
Case Else
MsgBox ("Vul een getal met 3 of 4 posities in"): GoTo fout
End Select
Application.EnableEvents = False
.Value = TimeSerial(Int(uur), Int(minuut), 0)
Application.EnableEvents = True
End With
Exit Sub
fout:
Application.EnableEvents = False
Target.Value = ""
Target.Activate
Application.EnableEvents = True
End Sub
oops even de "vraag" datum gemist.. ;-)