AW: Userform Problem
19.03.2025 13:05:22
Alwin Weisangler
sorry, hat ein wenig gebraucht bis ich die Verrenkung in Spalte 4 verstanden hatte.
dann ändere so:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim lCheckIn&, i&, j&, rng As Range, tmp$, iDatum As Variant
Application.EnableEvents = False
If TextBox1.Value = "" Then Exit Sub
Set rng = Tab2.UsedRange
If Not IsDate(TextBox1.Value) Then
MsgBox "Bitte nur ein gültiges Datum eingeben!", vbCritical, "!"
TextBox1.Value = ""
Exit Sub
End If
lCheckIn = CDate(TextBox1.Value)
If lCheckIn Date Then
MsgBox "Bitte kein Datum aus der Vergangenheit eingeben!", vbCritical, "!"
TextBox1.Value = ""
TextBox1.SetFocus
Exit Sub
End If
With rng
iDatum = Application.Match(CLng(CDate(TextBox1)), .Columns(4), 0)
For i = 2 To rng.Rows.Count
For j = 2 To rng.Columns.Count - 1
If Not IsError(iDatum) Then
If i = iDatum Then
If rng.Cells(i, 4) = CDate(TextBox1) Then tmp = tmp & rng.Cells(i, j) & "###"
End If
Else
tmp = tmp & rng.Cells(i, j) & "###"
End If
Next j
Next i
End With
j = 0
For i = 1 To 7
If InStr(1, tmp, i) = 0 Then
j = j + 1
Controls("pp" & j) = i
End If
Next i
End Sub
Gruß Uwe