Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default format of combobox on userform

Hi I have a combobox where the data is dates and a second where it is time.

For the dates combox, the list happily shows the dates in my required format
(ie dd mmm yyyy), but when you choose a date from the list it appears in the
box in the serial date format (ie 39123).

A similar thing happens with times. If I choose 08:00 from the list, it
shows as 0.33333333 (ie 8/24).

Is there a way I can format the visible value of the chosen item from the
combobox list so that it appears as it does in the list?

Many thanks.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default format of combobox on userform

In the VBA code editor window, try using this for the dates combo box:

Private Sub ComboBox1_Change()

ComboBox1.Value = Format(ComboBox1.Value, "m/d/yyyy")

End Sub


Likewise, for the times combo box try this:

Private Sub ComboBox2_Change()

ComboBox2.Value = Format(ComboBox2.Value, "h:mm")

End Sub

Hopefully this helps,
James



"red6000" wrote:

Hi I have a combobox where the data is dates and a second where it is time.

For the dates combox, the list happily shows the dates in my required format
(ie dd mmm yyyy), but when you choose a date from the list it appears in the
box in the serial date format (ie 39123).

A similar thing happens with times. If I choose 08:00 from the list, it
shows as 0.33333333 (ie 8/24).

Is there a way I can format the visible value of the chosen item from the
combobox list so that it appears as it does in the list?

Many thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default format of combobox on userform

With the code below, there is no reformatting of the displayed text, so show
the code that fills the combos and any formatting you do.

Private Sub UserForm_Initialize()
With ComboBox1
.AddItem Now()
.ListIndex = 0
End With
End Sub

Private Sub ComboBox1_Click()
With ComboBox1
Debug.Print "Text :" & .Text & vbNewLine & "Value: " & .Value
End With
End Sub

********* Debug Output *******
Text :19/07/06 11:19:08 AM
Value: 19/07/06 11:19:08 AM

"red6000" wrote in message
...
Hi I have a combobox where the data is dates and a second where it is

time.

For the dates combox, the list happily shows the dates in my required

format
(ie dd mmm yyyy), but when you choose a date from the list it appears in

the
box in the serial date format (ie 39123).

A similar thing happens with times. If I choose 08:00 from the list, it
shows as 0.33333333 (ie 8/24).

Is there a way I can format the visible value of the chosen item from the
combobox list so that it appears as it does in the list?

Many 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
ComboBox on a UserForm LLoyd Excel Worksheet Functions 2 February 20th 08 09:01 PM
format combobox in userform to accept dates Brad Excel Worksheet Functions 3 November 2nd 05 01:11 AM
Userform w/ComboBox D.Parker Excel Discussion (Misc queries) 2 May 6th 05 04:28 PM
Userform: Combobox, dates, match required- can't get date format to work KR Excel Programming 2 November 10th 04 05:18 PM
ComboBox on UserForm Michel[_4_] Excel Programming 2 July 31st 04 10:11 PM


All times are GMT +1. The time now is 05:49 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"