ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Combo Box Formatting problem (https://www.excelbanter.com/excel-programming/276175-excel-combo-box-formatting-problem.html)

Dan McCloud

Excel Combo Box Formatting problem
 
hello all,

I am trying to take a list of times (starting with 12:00 AM, 12:15 AM,
12:30 AM, etc. all the way to 11:45 PM) in one sheet and populate a
combo box in another sheet with these times for time entry. That part
I can handle.

However, when I click the box and transfer the value of the combo box
to the designated cell, I can't seem to format the resultant decimal
number (i.e. 0.62500002 for 3:00 PM) as a time.

I suspect that the problem lies with the fact that I can't seem to
change the data type of the combo box. It looks like it is a string
and the resultant number is actually a string.

One final observation before I pose the relevant questions: If I
click the combo box and get a value in the designated cell and then
click that cell and click into the 'formula edit bar' of the cell
(where you would edit a formula), as soon as I click out of the cell,
it changes to the desired format (3:00 PM).

So here are the questions:

1. Is there a way to change the data type of the combo box?

2. Is there a work around to this problem besides trying to change
the data type?

Dan McCloud

Excel Combo Box Formatting problem
 
Tom,

Thanks again for your help. I seem to have found a work around. I
didn't want to have to get into coding any of this, but this simple
piece of code seemed to do the trick. I wanted to follow up so that
anyone else with this problem may benefit.


Here's the code:

Range("B10").Select
ActiveCell.FormulaR1C1 = ComboTime.Text


"Tom Ogilvy" wrote in message ...
If isdate(Combobox1.Text) then
With worksheets("sheet1").Range("A1")
.Value = cdate(Combobox1.Text)
.NumberFormat = "hh:mm:ss"
End With
End if

Dates and time are all one format.

--
Regards,
Tom Ogilvy

"Dan McCloud" wrote in message
om...
hello all,

I am trying to take a list of times (starting with 12:00 AM, 12:15 AM,
12:30 AM, etc. all the way to 11:45 PM) in one sheet and populate a
combo box in another sheet with these times for time entry. That part
I can handle.

However, when I click the box and transfer the value of the combo box
to the designated cell, I can't seem to format the resultant decimal
number (i.e. 0.62500002 for 3:00 PM) as a time.

I suspect that the problem lies with the fact that I can't seem to
change the data type of the combo box. It looks like it is a string
and the resultant number is actually a string.

One final observation before I pose the relevant questions: If I
click the combo box and get a value in the designated cell and then
click that cell and click into the 'formula edit bar' of the cell
(where you would edit a formula), as soon as I click out of the cell,
it changes to the desired format (3:00 PM).

So here are the questions:

1. Is there a way to change the data type of the combo box?

2. Is there a work around to this problem besides trying to change
the data type?



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com