View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Get a date to display in date format on a UserForm

The example I posted worked fine for me with a ComboBox in a Userform with
various values in the Combo's List.

I've tried to think of all sorts of scenarios that might give rise to what
you describe and have narrowed it down to a ComboBox on a worksheet with
it's ListFillRange linked to cells that contain dates. If(?) that's what you
have, try reformatting the cell's numberformat from default to your date
format, start with any of the built in date formats then adapt in the
Custom field as required.

Regards,
Peter T

"ryguy7272" wrote in message
...
Thanks guys, but it is not working. I tried the following:
Cells(2, 13) = ComboBox1.Value
If ComboBox1.Value < "" Then
ComboBox1.Value = Format(CDate(ComboBox1.Value), "mm/dd/yyyy")
End If

and this.............
Cells(2, 13) = ComboBox1.Text
If ComboBox1.Text < "" Then
ComboBox1.Text = Format(CDate(ComboBox1.Text), "mm/dd/yyyy")
End If

Neither attempt worked. Any other ideas? When I click the down arrow,

the
dates appear as dates. When I click on a date (select it), it is

converted
into its serial format (i.e., 39539). Appreciate any help with this....



--
RyGuy


"Peter T" wrote:

dim s
With Me.ComboBox1
If Len(.Value) Then
On Error Resume Next
s = Format(CDate(.Value), "dd-mmm-yy")
On Error GoTo 0
If .Value < s And Len(s) Then .Value = s
End If
End With

Only change if it needs be or the combo's change even will run

repeatedly;
as written above it'll fire when changed but only the once and of no
consequence.

ComboBox1.Value = Format(ComboBox1.Value, "mm/dd/yyyy")
End If
However, I just see 39539 in the ComboBox when I really want to see

4/1/2008.

I assume you really want to see 04/01/2008

Regards,
Peter T



"ryguy7272" wrote in message
...
How can I get a date to display in date format on a UserForm? I

thought
it
would be something simple, such as the following:
If ComboBox1.Text < "" Then
ComboBox1.Value = Format(ComboBox1.Value, "mm/dd/yyyy")
End If
However, I just see 39539 in the ComboBox when I really want to see

4/1/2008.

Thanks in advance.
Ryan--


--
RyGuy