Array to ListBox
12.10.2017 08:56:23
Antonio
mein Problem is für mich etwas schwierig zu lösen.
Ich habe im Archiv das gefunden:
Private Sub cmdSearch_Click()
Dim c As Range
Dim rngBereich As Range
Dim lngAnzahl As Long
Dim strFirst As String
With Sheets("Daten")
Set rngBereich = .Columns("A:H")
Set c = rngBereich.Find(txtSearch, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
strFirst = c.Address
Do
ListBox1.AddItem .Cells(c.Row, 1)
lngAnzahl = ListBox1.ListCount
ListBox1.List(lngAnzahl - 1, 1) = .Cells(c.Row, 2)
ListBox1.List(lngAnzahl - 1, 2) = .Cells(c.Row, 3)
ListBox1.List(lngAnzahl - 1, 3) = .Cells(c.Row, 4)
ListBox1.List(lngAnzahl - 1, 4) = .Cells(c.Row, 5)
ListBox1.List(lngAnzahl - 1, 5) = .Cells(c.Row, 6)
ListBox1.List(lngAnzahl - 1, 6) = .Cells(c.Row, 7)
ListBox1.List(lngAnzahl - 1, 7) = .Cells(c.Row, 8)
Set c = rngBereich.FindNext(c)
Loop While Not c Is Nothing And c.Address strFirst
End If
End With
End Sub
umgeschrieben so das es für mich passt:With ListBox6 'ListBox6 füllen
.Clear
.ForeColor = RGB(0, 0, 255)
.ColumnCount = 11
.ColumnWidths = "0;0;350;0;0;0;0;0;0;0;0;0"
End With
Dim c As Range
Dim rngBereich As Range
Dim lngAnzahl As Long
Dim strFirst As String
With Sheets("Lampen")
Set rngBereich = .Columns("E:E")
Set c = rngBereich.Find(TextBox100.text, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
strFirst = c.Address
Do
ListBox6.AddItem .Cells(c.Row, 1)
lngAnzahl = ListBox6.ListCount
ListBox6.List(lngAnzahl - 1, 1) = .Cells(c.Row, 2)
ListBox6.List(lngAnzahl - 1, 2) = .Cells(c.Row, 3)
ListBox6.List(lngAnzahl - 1, 3) = .Cells(c.Row, 4)
ListBox6.List(lngAnzahl - 1, 4) = .Cells(c.Row, 5)
ListBox6.List(lngAnzahl - 1, 5) = .Cells(c.Row, 6)
ListBox6.List(lngAnzahl - 1, 6) = .Cells(c.Row, 7)
ListBox6.List(lngAnzahl - 1, 7) = .Cells(c.Row, 8)
ListBox6.List(lngAnzahl - 1, 8) = .Cells(c.Row, 9)
ListBox6.List(lngAnzahl - 1, 9) = .Cells(c.Row, 10)
' ListBox6.List(lngAnzahl - 1, 10) = .Cells(c.Row, 11)
' ListBox6.List(lngAnzahl - 1, 11) = .Cells(c.Row, 12)
Set c = rngBereich.FindNext(c)
Loop While Not c Is Nothing And c.Address strFirst
End If
End With
aber mit dieser Methode komme ich nicht über die 10 Spalten,
habe versucht ein Array zu bilden:
Dim c As Range
Dim rngBereich As Range
Dim arrFill As Variant
With Sheets("Lampen")
Set rngBereich = .Columns("E:E")
Set c = rngBereich.Find(TextBox100.text, LookIn:=xlValues, lookat:=xlPart)
arrFill = Sheets("Lampen").Range("Tabelle4")
ListBox6.List() = arrFill
End With
ohne Erfolgt, es wird mir immer die komplete Spalte(E) wieder gegeben und nicht nach den TextBox100.text.
Kann mich bitte jemandem ein Tipp geben?
Danke in Voraus
Antonio
Anzeige