Problem mit Code
26.12.2007 11:13:15
Martin
Ich habe einen Code welcher mir Daten anhand eines Kriteriums in Spalte I auswählt und dann in einer
Listbox ausgibt
Opt 1 - Opt 5 funktionieren wunderbar
nur Opt 6, welcher mir die gesamte Liste anzeigen soll Funktioniert nicht
ich weis nicht warum
Kann mir jemand helfen ?
Besten Dank im Vorraus
hier mein Code
Private Sub CommandButton1_Click()
Dim i As Integer, srcCol As Integer, srcChar As String
'Herr
If Me.Opt2 = True Then
srcChar = "H"
Else
'Frau
If Me.Opt3 = True Then
srcChar = "F"
Else
'Herr und Frau
If Me.Opt4 = True Then
srcChar = "B"
Else
'Familie
If Me.Opt5 = True Then
srcChar = "C"
Else
'Gesamt
If Me.Opt6 = True Then
srcChar = "H"
srcChar = "F"
srcChar = "B"
srcChar = "C"
End If
End If
End If
End If
End If
srcCol = 9 '9=i
With Me.ListBox1
.Clear
.ColumnCount = 8
For i = 2 To Cells(Rows.Count, srcCol).End(xlUp).Row
If InStr(1, Cells(i, srcCol), srcChar) > 0 Then
.AddItem Cells(i, 1)
.List(.ListCount - 1, 1) = Cells(i, 2) 'Spalten der Tabelle
.List(.ListCount - 1, 2) = Cells(i, 3)
.List(.ListCount - 1, 3) = Cells(i, 4)
.List(.ListCount - 1, 4) = Cells(i, 5)
.List(.ListCount - 1, 5) = Cells(i, 6)
.List(.ListCount - 1, 6) = Cells(i, 7)
.List(.ListCount - 1, 7) = Cells(i, 8)
.List(.ListCount - 1, 8) = Cells(i, 9)
End If
Next i
End With
End Sub
Gruß Martin