Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender

Forumthread: VBA Combobox Liste

VBA Combobox Liste
02.02.2022 15:45:14
Freddy
Hallo,
ich habe Comboboxen in einem Formular, die mit Daten aus einer Excel Liste. Der Code ist wie folgt:

Private Sub UserForm_Initialize()
'ComboBoxes füllen ohne doppelte Einträge
If ActiveSheet.Cells(2, 1).Text  "" Then
Dim hsh1 As Object, hsh2 As Object, hsh3 As Object, hsh4 As Object, hsh5 As Object, hsh6 As Object
Dim i As Long, lngLR As Long
Set hsh1 = CreateObject("Scripting.Dictionary")
Set hsh2 = CreateObject("Scripting.Dictionary")
Set hsh3 = CreateObject("Scripting.Dictionary")
Set hsh4 = CreateObject("Scripting.Dictionary")
Set hsh5 = CreateObject("Scripting.Dictionary")
Set hsh6 = CreateObject("Scripting.Dictionary")
With ActiveSheet
For i = 2 To .Cells(.Rows.Count, 3).End(xlUp).Row   'letzte Zeile in Spalte A
hsh1(.Cells(i, 14).Text) = 0                      'Rabatttyp
hsh2(.Cells(i, 5).Text) = 0                      '5 = Shop
hsh3(.Cells(i, 12).Text) = 0                      '12 = Unterkategorie
hsh4(.Cells(i, 11).Text) = 0                      '11 = Überkategorie (Typ)
hsh5(.Cells(i, 1).Text) = 0                      '1 = Beschreibung
hsh6(.Cells(i, 1).Text) = 0
Next
End With
NewProduct.ComboBox_rabatttyp.List = Application.Transpose(hsh1.Keys)
NewProduct.ComboBox_shop.List = Application.Transpose(hsh2.Keys)
NewProduct.ComboBox_basiccategory.List = Application.Transpose(hsh3.Keys)
NewProduct.ComboBox1_category.List = Application.Transpose(hsh4.Keys)
NewProduct.TextBox_caption.List = Application.Transpose(hsh5.Keys)
Set hsh1 = Nothing
Set hsh2 = Nothing
Set hsh3 = Nothing
Set hsh4 = Nothing
Set hsh5 = Nothing
End If
Ich möchte nun gerne eine weitere Combobox erstellen (Variable: hsh6) mit den Werten aus der Zelle und der Zeilennummer in eckiger Klammer vornedran (z.B. [6] Zellentext) angeben, sowie eine weiter Combobox mit nur der Zeilennummer erstellen.
Somit bitte ich um eure Hilfe!
Vielen Dank
Grüße Freddy
Anzeige

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: VBA Combobox Liste
02.02.2022 15:54:26
Rudi
Hallo,
hsh6(Format(i,"""[""0""] """) & .Cells(i, 1).Text) = 0
Gruß
Rudi
AW: VBA Combobox Liste
02.02.2022 16:08:07
Freddy
Danke, Rudy funktioniert bestens!
AW: VBA Combobox Liste
02.02.2022 16:15:47
Freddy
Haallo Rudy,
noch eine Frage. Wie kann ich nur die Zeilenangabe machen?

hsh7(Format(i, "0")) = 0
so hat es nicht geklappt.
Danke,
Grüße Freddy
Anzeige
was klappt da nicht? owT
02.02.2022 16:22:04
Rudi
AW: was klappt da nicht? owT
02.02.2022 16:27:20
Freddy
Habs rausgefunden, Danke!
So:

hsh7(.Cells(i, 1).Row) = 0
LG
Unsinn.
02.02.2022 16:29:07
Rudi
hsh7(i)=0
sollte auch reichen.
Anzeige
;

Forumthreads zu verwandten Themen

Anzeige
Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige