Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / October 2007

Tip: Looking for answers? Try searching our database.

Time format in code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
K1KKKA - 22 Oct 2007 20:44 GMT
HYCH.
The code below works for what i want, BUT !!

In the worksheet "Lists" i want the 1st combobox to show the values as
hh:mm but am getting the display as decimal, where do i format the
code below to show "hh:mm"

Any help please!!

Private Sub UserForm_Initialize()
Dim cPart As Range
Dim ws As Worksheet
Set ws = Worksheets("Lists")
For Each cPart In ws.Range("A1:A12")
 With Me.ComboBox1
   .AddItem cPart.Value
   .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
 End With
Next cPart
For Each cPart In ws.Range("B1:B7")
 With Me.ComboBox2
   .AddItem cPart.Value
   .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
 End With
Next cPart
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.ComboBox1.SetFocus
End Sub

Steve
Dave Peterson - 22 Oct 2007 21:28 GMT
If the cells are formatted correctly:
.List(.ListCount - 1, 1) = cPart.Offset(0, 1).Text

or apply the format you like:
.List(.ListCount - 1, 1) = format(cPart.Offset(0, 1).Value, "hh:mm")

> HYCH.
> The code below works for what i want, BUT !!
[quoted text clipped - 27 lines]
>
> Steve

Signature

Dave Peterson

K1KKKA - 22 Oct 2007 22:39 GMT
> If the cells are formatted correctly:
> .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Text
[quoted text clipped - 39 lines]
>
> - Show quoted text -

Cheers Dave, sorted

Steve

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.