ListBox mit nicht zusammenhängenden Bereich füllen
Hallo Excelfreunde,
wie kann ich eine ListBox in einer UserForm mit der Zelle D7 und den Bereich D9:173 füllen.
Gruß
fedjo
Antwort schreiben
Antwort 1 von meinTipp vom 21.08.2021, 19:09 Options
Hallo fedjo,
in etwa so:
Dim lngZeile as Long
With Listbox1
.AddItem = Worksheets("Blattname").Cells(7,4).Value
For lngZeile 9 To 173
.Additem = Worksheets("Blattname").Cells(lngZeile,4).Value
next lngZeile
End With
Gruss Rolf
Antwort 2 von fedjo vom 22.08.2021, 08:17 Options
Hallo Rolf,
danke für die schnelle Antwort.
Ich habe den Code in : Private Sub UserForm_Activate () eingefügt.
Es werden aber Fehler angzeigt
.AddItem = (Function oder Variable erwartet)
For lngZeile 9 To 173 (wird rot hinterlegt)
Ich hoffe das du mir noch weiterhelfen kannst.
Gruß
fedjo
Antwort 3 von Hajo_Zi vom 22.08.2021, 08:22 Options
Hallo Fedjo,
hat Deine Listbox den Namen Listbox1 ?
For lngZeile= 9 To 173
Gruß Hajo
Antwort 4 von fedjo vom 22.08.2021, 08:28 Options
Hallo Hajo,
es ist ListBox4.
Gruß
fedjo
Antwort 5 von Hajo_Zi vom 22.08.2021, 08:36 Options
Halo Fedjo,
dan konntest Du das Problem ja selber lösen.
Bei With muss der entsprechende Name hin.
Gruß Hajo
Antwort 6 von fedjo vom 22.08.2021, 08:39 Options
Hallo Hajo,
der Fehler :.AddItem = (Function oder Variable erwartet) tritt immer noch auf.
Gruß
fedjo
Antwort 7 von Hajo_Zi vom 22.08.2021, 08:47 Options
Hallo Fedjo,
sollte das der gleiche Fehler wie vorher sein. Hat Deine Tabelle nicht den Namen "Blattname" ?
Gruß Hajo
Antwort 8 von fedjo vom 22.08.2021, 09:26 Options
Hallo Hajo,
der Fehler bleibt bestehen.
Gruß
fedjo
Dim lngZeile As Long
With ListBox4
.AddItem = Worksheets("Allgemein").Cells(7, 4).Value
For lngZeile = 9 To 173
.AddItem = Worksheets("Allgemein").Cells(lngZeile, 4).Value
Next lngZeile
End With
Antwort 9 von Hajo_Zi vom 22.08.2021, 09:31 Options
Hallo Fedjo,
die kleinen Zeichen.
Option Explicit
Private Sub UserForm_Activate()
Dim lngZeile As Long
With ListBox4
.AddItem Worksheets("Allgemein").Cells(7, 4).Value
For lngZeile = 9 To 173
.AddItem Worksheets("Allgemein").Cells(lngZeile, 4).Value
Next lngZeile
End With
End Sub
Gruß Hajo
Antwort 10 von fedjo vom 22.08.2021, 09:50 Options
Hallo Hajo,
ich habe eine Weile gebraucht um das kleine Zeichen zu finden.
Jetzt funktioniert alles.
Herzlichen Dank für deine Hilfe und Geduld.
Gruß
fedjo