Hallo liebe Gemeinde,
ich habe ein Problem welchem ich nicht auf die schliche komme.
Ich habe ein Userform in welchem sich 3 Comboboxen befinden. Zwei davon befülle ich mit einer Schleife und einem variablen Startwert.
Es geht letztendlich um Uhrzeit/Arbeitszeiten.
Combobox 1 und 2 werden durch die Schleife befüllt. Wenn ich jetzt als Startzeit 18:00 habe und als Endzeit 15:00 dann befüllt die Schleife die Combobox richtig, aber wenn ich eine Startzeit von 6:00 bis 15:00 habe dann lässt er die letzte viertel Stunde einfach weg und endet bei 14:45. Dieses Phänomen habe ich auch, wenn die Startzeit kleiner ist als die Endzeit.
Woran liegt das???
mfg Gast
Private Sub UserForm_Initialize()
Dim n, i, x As Integer
Dim e, r As Double
x = 0
r = Cells(Selection.Row, 5)
If Cells(Selection.Row, 5) < Cells(Selection.Row, 4) Then
For e = Cells(Selection.Row, 4) To 1 Step 1 / 96
ComboBox2.AddItem Format(e, "hh:mm")
ComboBox1.AddItem Format(e, "hh:mm")
x = x + 1
Next
For e = 1 / 96 To r Step 1 / 96
ComboBox2.AddItem Format(e, "hh:mm")
ComboBox1.AddItem Format(e, "hh:mm")
x = x + 1
Next
Else
For e = Cells(Selection.Row, 4) To r Step 1 / 96
ComboBox2.AddItem Format(e, "hh:mm")
ComboBox1.AddItem Format(e, "hh:mm")
x = x + 1
MsgBox e
Next
End If
x = x - 1
ComboBox3.AddItem "Ja"
ComboBox3.AddItem "Nein"
ComboBox1.SetFocus
ComboBox1.ListIndex = 0
ComboBox2.SetFocus
ComboBox2.ListIndex = x
ComboBox3.SetFocus
ComboBox3.ListIndex = 0
ComboBox1.Enabled = False
ComboBox2.Enabled = False
End Sub
|