Daten werden in die ListBox2 nicht eingelesen
24.02.2009 13:59:12
Josef
mit unten stehendem Code werden die Daten aus der UserForm "frmStellenplan" in die Userform4 in die ListBox1 eingetragen.
In der ListBox2 erfolgt jedoch kein Eintrag.
Warum erfolgt bitte kein Eintrag in die ListBox2?
Wass mache ich hier bitte falsch?
Ist es vielleicht der IF Befehl?
Private Sub UserForm_Initialize()
Dim aRow As Long
Dim iRow As Long
Dim wks As Worksheet
Set wks = Workbooks("Stellenpläne.xls").Worksheets("Tabelle1")
Dim lCoBo As Long
If frmStellenplan.ComboBox33.Value = "Auswahl nach PA oder FA, BLD und Politischem Bezirk" And _
_
frmStellenplan.ComboBox49.Value = "JA" Then
With ListBox1
.Clear ' löschen ComboBox
.ColumnCount = 10 ' drei Spalten
.ColumnWidths = "1,5 cm;1,6 cm;4,4 cm;3,5 cm;1,4 cm;4,7 cm;2,2 cm;2 cm;1,1 cm" ' Breite _
der Spalten
End With
aRow = IIf(IsEmpty(wks.Range("A65536")), wks.Range("A65536").End(xlUp).Row, 65536)
For iRow = 2 To aRow
With wks
If .Cells(iRow, 33) = frmStellenplan.ComboBox45 _
And .Cells(iRow, 4) = frmStellenplan.ComboBox46 _
And .Cells(iRow, 20) = frmStellenplan.ComboBox47 _
And .Cells(iRow, 14) = frmStellenplan.ComboBox49 Then
If Err = 0 And _
wks.Cells(iRow, 14) = _
frmStellenplan.ComboBox49.Value Then
ListBox1.AddItem ""
ListBox1.List(lCoBo, 0) = _
wks.Cells(iRow, 1)
ListBox1.List(lCoBo, 1) = _
wks.Cells(iRow, 5)
ListBox1.List(lCoBo, 2) = _
wks.Cells(iRow, 6)
ListBox1.List(lCoBo, 3) = _
wks.Cells(iRow, 7)
ListBox1.List(lCoBo, 4) = _
wks.Cells(iRow, 8)
ListBox1.List(lCoBo, 5) = _
wks.Cells(iRow, 9)
ListBox1.List(lCoBo, 6) = _
wks.Cells(iRow, 10)
ListBox1.List(lCoBo, 7) = _
wks.Cells(iRow, 11)
If frmStellenplan.CheckBox2.Value = True Then
ListBox1.List(lCoBo, 8) = _
wks.Cells(iRow, 3)
Else
If frmStellenplan.CheckBox2.Value = False Then
ListBox1.List(lCoBo, 8) = _
wks.Cells(iRow, 14)
End If
End If
lCoBo = lCoBo + 1
Else
Err.Clear
End If
End If
End With
Next iRow
End If
If frmStellenplan.ComboBox33.Value = "Auswahl nach PA oder FA, BLD und Politischem Bezirk" And _
_
frmStellenplan.ComboBox50.Value = "NEIN" Then
With ListBox2
.Clear ' löschen ComboBox
.ColumnCount = 10 ' drei Spalten
.ColumnWidths = "1,5 cm;1,6 cm;4,4 cm;3,5 cm;1,4 cm;4,7 cm;2,2 cm;2 cm;1,1 cm" ' Breite _
der Spalten
End With
aRow = IIf(IsEmpty(wks.Range("A65536")), wks.Range("A65536").End(xlUp).Row, 65536)
For iRow = 2 To aRow
With wks
If .Cells(iRow, 33) = frmStellenplan.ComboBox45 _
And .Cells(iRow, 4) = frmStellenplan.ComboBox46 _
And .Cells(iRow, 20) = frmStellenplan.ComboBox47 _
And .Cells(iRow, 14) = frmStellenplan.ComboBox50 Then
If Err = 0 And _
wks.Cells(iRow, 14) = _
frmStellenplan.ComboBox50.Value Then
ListBox2.AddItem ""
ListBox2.List(lCoBo, 0) = _
wks.Cells(iRow, 1)
ListBox2.List(lCoBo, 1) = _
wks.Cells(iRow, 5)
ListBox2.List(lCoBo, 2) = _
wks.Cells(iRow, 6)
ListBox2.List(lCoBo, 3) = _
wks.Cells(iRow, 7)
ListBox2.List(lCoBo, 4) = _
wks.Cells(iRow, 8)
ListBox2.List(lCoBo, 5) = _
wks.Cells(iRow, 9)
ListBox2.List(lCoBo, 6) = _
wks.Cells(iRow, 10)
ListBox2.List(lCoBo, 7) = _
wks.Cells(iRow, 11)
If frmStellenplan.CheckBox2.Value = True Then
ListBox2.List(lCoBo, 8) = _
wks.Cells(iRow, 3)
frmStellenplan.Label172.Caption = "FG"
Else
If frmStellenplan.CheckBox2.Value = False Then
ListBox2.List(lCoBo, 8) = _
wks.Cells(iRow, 14)
frmStellenplan.Label172.Caption = "WGKK"
End If
End If
lCoBo = lCoBo + 1
Else
Err.Clear
End If
End If
End With
Next iRow
End If
End Sub
Danke
Josef