I have the following Excel spreadsheet:
A B 1 ComboBox1 2 1.000 3 10.000 4 100.000 5
This list is loaded into a ComboBox using the following VBA:
Sub UserForm_Activate() ComboBox1.List = Sheet1.Range("A2:A4").Value End Sub
All this works fine so far.
The issue I have now is that the values in range A2:A4 are using a thousands seperator but when I load it into the ComboBox the thousands seperator are deleted. How can I display the values in my ComboBox with the thousands seperator as well?
To show the thausand separators, you can format the values to strings and put the separator there. This is dones with the format function –
Format(10000, "#,##0.00"). Then the values should be saved as array of strings and this array is the one, which is passed as a source to the
Sub UserForm_Activate() Dim myArr As Variant Dim myRng As Range Set myRng = Range("A1:A4") ReDim myArr(myRng.Cells.Count) Dim i As Long For i = LBound(myArr) To UBound(myArr) myArr(i) = Format(myRng.Cells(i + 1), "#,##0.00") Next i ComboBox1.List = myArr End Sub
This is how it looks like: