Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting cells from a value in a Listbox davethewelder Excel Programming 2 March 3rd 08 02:55 PM
Formatting Listbox Hardy03 Excel Discussion (Misc queries) 0 August 4th 05 12:43 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 4 November 18th 04 03:24 PM
Having a hard time with listbox Thurman Excel Programming 3 September 7th 03 11:22 PM
Date formatting in a multi column listbox Nigel Brown[_2_] Excel Programming 2 September 3rd 03 11:29 AM


All times are GMT +1. The time now is 02:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"