AW: UserForm, TextBox mit 2 Bedingungen
13.04.2022 10:39:22
Tim
Also, dank deiner Hilfe konnte ich das so Editieren, dass ich beide TextBoxen sowie beide CommandButtons nutzen konnte.
Jetzt müsste mir nur noch in der TextBox auch die Zahl angezeigt werden, sofern dort eine Zahl von 0-24 steht und eine Fehlermeldung sobald ich auf den Button Klicke, aber vergessen Habe den "Namen" oder "Datum" auszuwählen
Option Explicit
Dim Calendar1 As Object
Private Sub UserForm_Initialize()
'Calendar einlesen
Set Calendar1 = New cCalendar
Calendar1.Add_Calendar_into_Frame Me.Frame1
'ListBox befüllen 'Additem
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "70;80"
Dim i As Integer
Dim x As Integer
Dim sh As Worksheet
Set sh = Sheets("Datenbank")
For i = 4 To 83
If sh.Cells(i, 13) "" And sh.Cells(i, 14) "" Then
ListBox1.AddItem sh.Cells(i, 13)
ListBox1.List(x, 1) = sh.Cells(i, 14)
x = x + 1
End If
Next i
End Sub
Private Sub DatumEingereicht()
Dim i As Long, j As Long, k As Long, varName1 As String, varName2 As String
varName1 = ListBox1.List(ListBox1.ListIndex, 0)
varName2 = ListBox1.List(ListBox1.ListIndex, 1)
With Tabelle4
For i = 16 To 381
If .Cells(3, i) = Calendar1.Value Then j = i
Next i
For i = 4 To 83
If .Cells(i, 13) = varName1 Then
If .Cells(i, 14) = varName2 Then
k = i
GoTo schreiben
End If
End If
Next i
schreiben:
.Cells(k, j) = CDbl(TextBox1)
End With
End Sub
Private Sub DatumAufgebaut()
Dim i As Long, j As Long, k As Long, varName1 As String, varName2 As String
varName1 = ListBox1.List(ListBox1.ListIndex, 0)
varName2 = ListBox1.List(ListBox1.ListIndex, 1)
With Tabelle4
For i = 382 To 748
If .Cells(3, i) = Calendar1.Value Then j = i
Next i
For i = 4 To 83
If .Cells(i, 13) = varName1 Then
If .Cells(i, 14) = varName2 Then
k = i
GoTo schreiben
End If
End If
Next i
schreiben:
.Cells(k, j) = CDbl(TextBox2)
End With
End Sub
Private Sub CommandButton1_Click()
'Button1 eingereicht
DatumEingereicht
End Sub
Private Sub CommandButton2_Click()
'Button2 aufgebaut
DatumAufgebaut
End Sub
Private Sub CommandButton3_Click()
'Button3 beenden
Unload Stunden
End Sub