Time Format in a ComboBox

G

Guest

I have recently had a problem with date formats in ComboBoxes Joel solved the
problem with this: string_date = format(mydate,"mm-dd-yy"). Continuing with
the form I now want to add a ComboBox to select a time from a range of cells.
I thought I could modify the code above to string_time =
format(mytime,"hh:mm") and indeed all is well until I select 12:00 when the
ComboBox shows it as 00:05. All other time are correct! Any suggestion would
be gratefully received. Many thanks Graham
 
G

Guest

It is accurately showing the time in mytime. Not sure where mytime actuall
came from. I would temproarily reformat the range of cells that contain the
time to that shows minutes. I think you will find that 12:00 is set to
12:05. When you display 12:05 as only hours it will show up as 12.
 
G

Guest

Hi Joel, no success i'm afraid, perhaps I have not supplied enough info. This
is the routine in the userform
Private Sub Time_Box_Change()
mytime = Time_Box.Value
string_time = Format(mytime, "hh:mm")
Time_Box.Value = string_time
End Sub

It may not be elegant... The Row Source for the Time_Box Combobox is set to
a single row of cells on the worksheet all formatted to "hh:mm" all show a
time between 09:00 and 17:00 in 30 min periods. The variables all show the
correct contents when various times are selected until I select 12:00 when
all the variables contain "00:05" I have tried deleteing the range on the
worksheet, moved it to another area, all without success

Joel said:
It is accurately showing the time in mytime. Not sure where mytime actuall
came from. I would temproarily reformat the range of cells that contain the
time to that shows minutes. I think you will find that 12:00 is set to
12:05. When you display 12:05 as only hours it will show up as 12.
If you could help I would be grateful.

Many thanks

Graham
 
G

Guest

Try this:

Enter in the 1st two cells of your time row 9:00 and 9:30. Then copy this
sequence to the other cells by following these instructions

Select the two cells with 9:00 and 9:30. Then entend this range by clicking
on the little square on the bottom right corner of the two selected cells and
pulling the square box down the row until you get to the last row (5:00).
See if 12:00 is correct.

I did this and then use your format statement and got the corect time.
 
G

Guest

Hi Joel, Strangely enough that is how I entered the times. I think I will try
re writing the workbook from scratch. Many thanks for your time, I will let
you know how I get on! Best wishes Graham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top