Reputation: 431
Hello I have this Excel Spreadsheet
I would like to fill my combobox ComboBox1
only with the numbers in the given range.
So far I used this code to fill a combobox
With Worksheets("mySheet")
ComboBox1.List = .Range("A1", .Range("A" & Rows.Count).End(xlUp)).Value
End With
But this function fills my Combobox with all the values. Is there a way to make ComboBox recognize only numbers?
Edit:
With the isNumeric()
worked nice but it inserts blank spaces like the picture below
Thank you in advance.
Upvotes: 0
Views: 487
Reputation: 5902
You can add a check like below.
For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
If IsNumeric(Range("A" & i).Value) And Range("A" & i).Value <> "" Then ComboBox1.AddItem Range("A" & i).Value
Next i
Upvotes: 1