简体   繁体   中英

Excel VBA filling combobox with list shows #####?

I have a list of times (displaying 1:00 PM) in a column on the sheet, and I'm trying to load it into the userform:

Dim Converter() As String
ReDim Converter(LastRow)
For i = 0 To (LastRow)
    Converter(i) = Cells(i, 1).Text
Next i
JobStartSelect.List = Converter()

When I zoom out to the point where excel converts some of the longer times to #####, I notice my combobox list will also show #####, even if the list box itself has more than enough space. Is there any way to fix this?

Preferably I can load it into the combobox as a time value completely, which might fix this issue, since I plan to do calculations with it. As it stands, I'm using the text to fill the combobox, then separately loading the value to do calculations with.

Try

Converter(i) = Cells(i, 1).Value2

or

Converter(i) = format(Cells(i, 1),"hh:mm:ss AM/PM")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM