Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox Time Formatting
I have created a listbox using the following code:
With ThisWorkbook.Sheets("inventory") vList = .Range("a2", .Range("a2").End(xlDown).Offset(0, 3)) End With Me.lst_inventory.ListStyle = fmListStyleOption frm_inventory.lst_inventory.List = vList The last two columns are start and end times, formatted as HH:MM AM/PM on the worksheet. When brought into the Listbox, the times are shown as their serial numbers (ie .2500). Is there a way to format the appearance of the time fields in the Listbox using the method of creating the listbox as shown above? Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listbox Time Formatting
Your code uses the Value property of each cell by default since you didn't
specify one. You have to use the Text property. I think you have to go through the cells individually to do that: Private Sub UserForm_Initialize() Dim rgList As Range Dim Cell As Range With ThisWorkbook.Sheets("inventory") Set rgList = .Range("a2", .Range("a2").End(xlDown)).Offset(0, 3) End With lst_inventory.ListStyle = fmListStyleOption For Each Cell In rgList lst_inventory.AddItem Cell.Text Next End Sub -- Jim "dunnerca" wrote in message ... |I have created a listbox using the following code: | | With ThisWorkbook.Sheets("inventory") | vList = .Range("a2", .Range("a2").End(xlDown).Offset(0, 3)) | End With | Me.lst_inventory.ListStyle = fmListStyleOption | frm_inventory.lst_inventory.List = vList | | The last two columns are start and end times, formatted as HH:MM AM/PM on | the worksheet. | | When brought into the Listbox, the times are shown as their serial numbers | (ie .2500). Is there a way to format the appearance of the time fields in | the Listbox using the method of creating the listbox as shown above? | | Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting cells from a value in a Listbox | Excel Programming | |||
Formatting Listbox | Excel Discussion (Misc queries) | |||
time formatting and time categorizing (vlookup or data validation) | Excel Worksheet Functions | |||
Having a hard time with listbox | Excel Programming | |||
Date formatting in a multi column listbox | Excel Programming |