AW: Dictionary an UserForm übergeben
28.07.2022 14:40:39
Tim
Habe jetzt einmal alles entfernt, was nichts mit dem Dictionary zu tun hat.
Alle Variablen, die verwendet werden sind auch definiert und funktionieren. Hier der Code aus Modul 1:
Option Explicit
Public projectlist As Object
Sub ImportProjektdaten2()
Dim projectName As Variant
Dim projectRange As Variant
Dim projectRangeStart As Variant
Dim projectRangeEnd As Variant
'Projektfläche definieren (3 Spalten mit Überschrift)
Set projectRangeStart = Cells(lastRow, lastColumn)
Set projectRangeEnd = Cells(201, lastColumn + 2)
projectRange = Range(projectRangeStart, projectRangeEnd).Address
'Projekt zu projectlist hinzufügen
projectlist.Add projectName, projectRange
End Sub
Sub DeleteProject()
projectlist.Remove (projectName)
End Sub
Sub AddProjectlist()
Set projectlist = New Scripting.Dictionary
End Sub
Und hier der Code, der sich auf UserForm1 findet:
Option Explicit
Private Sub UserForm_Initialize() 'Daniels Code
Dim key As Variant, arrLbx(), n
ReDim arrLbx(1 To projectlist.Count, 1 To 2)
For Each key In projectlist.Keys
n = n + 1
arrLbx(n, 1) = key
arrLbx(n, 2) = projectlist(key)
Next key
With ListBox1
.ColumnCount = 2
.List = arrLbx
End With
End Sub
Ausgegeben werden sollen nur die Keys