Code auf 5 ListBoxes ausweiten - Wie?
Wolfgang
den nachstehenden Code erhielt ich hier aus dem Forum. Er sortiert in ListBox1 die Einträge alphabetisch und zeigt sie entsprechend in der Listbox an. Gibt es eine Möglichkeit, dass alle ListBoxes 1-5 jeweils auch Spalte A:E alphabetisch sortiert werden könnten. Wie müßte ich den Code abändern?
Danke schon jetzt für die Rückmeldungen.
Gruß - Wolfgang
Option Explicit
Public Function UniqueList(Matrix As Range, Optional VisibleCellsOnly As Boolean = True, _
Optional IncludeNull As Boolean = True, Optional Sorted As Boolean = True) As Variant
Dim objDic As Object, rng As Range, varTmp() As Variant, vntExclude As Variant
Set objDic = CreateObject("Scripting.Dictionary")
vntExclude = IIf(IncludeNull, "", 0)
If VisibleCellsOnly Then Set Matrix = Matrix.SpecialCells(xlCellTypeVisible)
For Each rng In Matrix.Cells
If rng.Value vntExclude Then objDic(rng.Value) = 0
Next
varTmp = objDic.keys
If Sorted Then QuickSort varTmp
UniqueList = varTmp
Set objDic = Nothing
End Function
Private Sub QuickSort(data() As Variant, Optional UG, Optional OG)
Dim P1&, P2&, T1 As Variant, T2 As Variant
UG = IIf(IsMissing(UG), LBound(data), UG)
OG = IIf(IsMissing(OG), UBound(data), OG)
P1 = UG
P2 = OG
T1 = data((P1 + P2) / 2)
Do
Do While (data(P1) T1)
P2 = P2 - 1
Loop
If P1 P2)
If UG
With Worksheets("Maßnahmen")vntList = UniqueList(.Range("A2:A" & Application.Max(2, .Cells(.Rows.Count, 1).End(xlUp).Row)))