Hallo Peer,
teste mal:
Private Sub UserForm_Initialize()
Dim zeile As Long
Dim Repeatings As Integer
Dim N As Integer
Dim letzte As Range
Dim i As Long
Dim wks As Worksheet
Dim HeimatOrt As String
Dim ETS As String
Set wks = Worksheets("Parameter")
With wks
HeimatOrt = .Cells(18, 3).Value & " " & .Cells(18, 4).Value & ", " & .Cells(18, 5).Value
ETS = .Cells(21, 3).Value & " " & .Cells(21, 4).Value & ", " & .Cells(21, 5).Value
End With
zeile = ActiveCell.Row
'Arbeitstag
txt_ArbZ_Beginn.Value = Format(Cells(zeile, 20), "hh:mm") 'Beginn
txt_ArbZ_Ende.Value = Format(Cells(zeile, 21), "hh:mm") 'Ende
txt_ArbZeit.Value = Format(Cells(zeile, 22), "hh:mm") 'Arbeitszeit abzgl Pause
lbl_Kalendertag = Cells(zeile, 2)
cbx_Reisezweck = Cells(zeile, 26)
'cbx_Zielort = Cells(zeile, 31)
chx_FAE = Cells(zeile, 7)
'Verwendung
If Cells(zeile, 4) = "Ausbilder" Then
Me.opt_Ausbilder.Value = True
txt_SchichtNr.Visible = False
ElseIf Cells(zeile, 4).Text = "Krank" Then
Me.opt_Krank.Value = True
txt_SchichtNr.Visible = False
ElseIf Cells(zeile, 4).Text = "Urlaub" Then
Me.opt_Urlaub.Value = True
txt_SchichtNr.Visible = False
ElseIf Cells(zeile, 4).Text = "Ruhe" Then
Me.opt_Ruhe.Value = True
txt_SchichtNr.Visible = False
ElseIf Cells(zeile, 4).Text = "Schicht" Then
Me.opt_Schicht.Value = True
txt_SchichtNr.Visible = True
txt_SchichtNr = Cells(zeile, 5)
End If
'Pause
If Cells(zeile, 24) = "" Then
Me.opt_Pause0.Value = True
ElseIf Cells(zeile, 24).Text = "0:30" Then
Me.opt_Pause30.Value = True
ElseIf Cells(zeile, 24).Text = "0:45" Then
Me.opt_Pause45.Value = True
End If
'PTZ
If Cells(zeile, 12) = "1" Then
Me.opt_PTZ1.Value = True
ElseIf Cells(zeile, 11) = "1" Then
Me.opt_PTZ2.Value = True
End If
'Abgabeart
If Cells(zeile, 33) = "App" Then
Me.opt_App.Value = True
ElseIf Cells(zeile, 33) = "Papier" Then
Me.opt_Papier.Value = True
End If
'Dienstreise
If txt_BeginnDatum > 0 Then
chk_Dienstreise.Value = True
ElseIf txt_BeginnDatum = 0 Then
chk_Dienstreise.Value = False
End If
txt_BeginnDatum = Cells(zeile, 27)
txt_BeginnZeit = Format(Cells(zeile, 28), "hh:mm")
txt_EndeDatum = Cells(zeile, 30)
txt_EndeZeit = Format(Cells(zeile, 31), "hh:mm")
txt_BeginnOrt = Cells(zeile, 29).Value
If txt_BeginnOrt.Text = HeimatOrt Then
opt_HeimatOrt.Value = True
opt_AndererOrt.Value = False
opt_ETS.Value = False
ElseIf txt_BeginnOrt.Text = ETS Then
opt_AndererOrt.Value = False
opt_HeimatOrt.Value = False
opt_ETS.Value = True
End If
' If txt_BeginnOrt.Value = HeimatOrt.Text Then 'wks.Cells(18, 3) & " " & wks.Cells(18, 4) & ", " & wks.Cells(18, 5).Text Then
' opt_HeimatOrt.Value = True
' opt_AndererOrt.Value = False
' opt_ETS.Value = False
' ElseIf txt_BeginnOrt.Value = ETS.Text Then 'wks.Cells(21, 3) & " " & wks.Cells(18, 4) & ", " & wks.Cells(21, 5).Text Then
' opt_AndererOrt.Value = False
' opt_HeimatOrt.Value = False
' opt_ETS.Value = True
' End If
txt_Zieladresse = Cells(zeile, 32)
txt_Abgabe = Cells(zeile, 34)
txt_Bearbeitung = Cells(zeile, 35)
txt_Auszahlung = Cells(zeile, 36)
txt_Bemerkungen = Cells(zeile, 37)
'Sheet "Reiseziele" Spalten auslesen
'With Me.cbx_Zielort
' .ColumnCount = 2
' .BoundColumn = 2
' .TextColumn = 2
' For Repeatings = 1 To Sheets("Reiseziele").Range("A65536").End(xlUp).Row
' .AddItem
' N = .ListCount - 1
' .List(N, 0) = Sheets("Reiseziele").Cells(Repeatings, 1)
' .List(N, 1) = Sheets("Reiseziele").Cells(Repeatings, 2)
' .List(N, 2) = Sheets("Reiseziele").Cells(Repeatings, 3)
' ' .List(N, 3) = Sheets("Reiseziele").Cells(Repeatings, 4)
' ' .List(N, 4) = Sheets("Reiseziele").Cells(Repeatings, 5)
' ' .List(N, 5) = Sheets("Reiseziele").Cells(Repeatings, 6)
' Next
'End With
'(zentriert) zeigt UF in Fenstermitte bei mehr als einem Monitor --------
Dim sngTop As Single, sngLeft As Single
Me.StartUpPosition = 0
sngLeft = Application.Left + Application.Width / 2 - Me.Width / 2
sngTop = Application.Top + Application.Height / 2 - Me.Height / 2
Me.Left = sngLeft
Me.Top = sngTop
'(zentriert) ENDE -------------------------------------------------------
End Sub
Gruß
Nepumuk