hej,
I want to populate combobox with unique value from a range.
the code working not properly, combobox not sorted and fylls allso with empty line (se the result/picture), (the code works only if the value is in a column and do not hanve eny empy cell)
thanks for help,
here is the code and the data.
I want to populate combobox with unique value from a range.
the code working not properly, combobox not sorted and fylls allso with empty line (se the result/picture), (the code works only if the value is in a column and do not hanve eny empy cell)
thanks for help,
here is the code and the data.
VBA Code:
Dim UfDic As Object
Dim Cl As Range
Set UfDic = CreateObject("scripting.dictionary")
UfDic.CompareMode = 1
With Sheets("Sheet1")
For Each Cl In .Range("AG2", "AI17")
If Not UfDic.exists(Cl.Value) Then UfDic.Add Cl.Value, CreateObject("scripting.dictionary")
Set UfDic(Cl.Value)(Cl.Offset(, -1).Value) = Cl
Next Cl
End With
Me.Page8ComboBox1.List = UfDic.keys
Year1 | Year2 | Year3 |
2017 | 2018 | 2019 |
2020 | 2021 | 2022 |
2020 | 2021 | 2022 |
2018 | ||
2015 | ||
2016 | ||
2017 | 2018 | |
2020 | ||
2015 | ||
2016 | ||
2017 | ||
2018 | 2019 | 2020 |
2019 | ||
2019 | ||
2018 | ||
2021 | 2022 |