Time format on userform

rs2k

Well-known Member
Joined
Aug 15, 2004
Messages
1,413
On my userform I have two combo boxes which have time values in 15 minute increments, which are filled from a WS (07:00,07:15,07:30 etc... upto 23:00) I have formated the combo boxes with "Hh:Mm" all is working correctly except when I choose 12:00 (Mid-day) it displays 00:05.
I have changed the vale in the combobox to 12:01 and it works fine, but it is bugging me that I cant have 12:00.
Can anyone shed some light on this, or tell me were I am going wrong?

Many thanks
Colin.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Still struggling. Can anyone please tell me why it is displaying 00:05 and not 12:00?
Any help on this would be greatfully appreciated.

Many thanks
Colin.
 
Upvote 0
Colin

How have you 'formatted' the combobox?

How are you populating it from the sheet?

Are you just using the times on the sheet to populate the combobox?
 
Upvote 0
The row source property =Time. The named range 'Time' is formatted with[hh]:mm.

the code for the combo box is;
Private Sub cmbBookingsTimeFrom_Change()
frmBookings.cmbBookingsTimeFrom.Value = Format (cmbBookingsTimeFrom.Value, "hh:mm")
End Sub

As in the initial post, all the other times are displaying correctly, just the 12:00 time isn't

(Please excuse if I take my time, the only PC with a net connection hasn't got Excel on it and the one I am working on is in another room)

Many thanks for your time
Colin.
 
Upvote 0
Colin

Have you considered populating the combobox with the AddItem method?
 
Upvote 0
Perhaps something like this.
Code:
Private Sub UserForm_Initialize()
Dim H As Long
Dim M As Long
    For H = 7 To 23
        For M = 0 To 45 Step 15
            ComboBox1.AddItem Format(H, "00") & ":" & Format(M, "00")
        Next M
    Next H
End Sub
The only problem here is that the values in the combobox are text, not time values. So if you are using them in calculations you would need to convert them to time values using TimeValue.
 
Upvote 0
Norie,
I formated the range on the WS as text, so the combo box doesn't display time values, just text, when it is copied over to the sheet where the calculations are, it is converted to time values there. Not the neatest, but it works.

Thanks for your help,

Colin.
 
Upvote 0

Forum statistics

Threads
1,226,216
Messages
6,189,675
Members
453,562
Latest member
overmyhead1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top