Live-Forum - Die aktuellen Beiträge
Datum
Titel
23.04.2024 14:59:21
23.04.2024 14:47:39
23.04.2024 14:23:45
Anzeige
Archiv - Navigation
1052to1056
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Daten werden in die ListBox2 nicht eingelesen

Daten werden in die ListBox2 nicht eingelesen
24.02.2009 13:59:12
Josef
Hallo!
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

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Daten werden in die ListBox2 nicht eingelesen
24.02.2009 14:15:04
Peter
Hallo Josef,
dann füge doch einfach einen Stop ein und prüfe die If-Bedingungen.
Auf was steht Err und sind die wks.Cells(iRow, 14) = frmStellenplan.ComboBox50.Value
Stop
If Err = 0 And _
wks.Cells(iRow, 14) = _
frmStellenplan.ComboBox50.Value Then
Gruß Peter
AW: Daten werden in die ListBox2 nicht eingelesen
24.02.2009 14:24:43
Josef
Hallo Peter!
Danke für Deine Antwort.
Wenn ich den Code der ComboBox49 in die Userform Initialize und den code der ComboBox50 in Userform Activate gebe, funktioniert alles bestens.
Da es aber verschiedene Eintragungen (z.B. ComboBox 55 und 56 usw. )gibt funktioniert das leider auch nicht.
Wo und wie sollte ich den Stop bitte setzen?
Danke
Josef
Anzeige
AW: Daten werden in die ListBox2 nicht eingelesen
24.02.2009 15:07:11
Peter
Hallo Josef,
setz den Stop so, wie gezeigt unmittelbar vor dem If
Nun kannst du mit F8 Schritt für Schritt die Befehle durchlaufen und dir auch die Inhalte deiner Variablen ansehen.
Du kannst natürlich anstelle des Stop auch
MsgBox "Err = " & Err & " wks.Cells(iRow, 14) = " & wks.Cells(iRow, 14) & " frmStellenplan.ComboBox50.Value = " & frmStellenplan.ComboBox50.Value
einfügen, dann bekommst du die Daten schon einmal angezeigt.
Gruß Peter

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige