View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Get a date to display in date format on a UserForm

Eureka! I got it; it just had to be inside the sub that was identified with
the ComboBox!! Here is the solution:

Private Sub ComboBox1_Change()
If ComboBox1.Text < "" Then
ComboBox1.Text = Format(CDate(Cells(2, 13).Text), "mm/dd/yyyy")
End If
'etc......

End Sub

Thanks for the help everyone, especially JP!! Thanks for being patient and
pushing me in the right direction!!

Cheers,
Ryan--

--
RyGuy


"JP" wrote:

Another thought -- maybe you should be using CDate on Cells(2,13), not
on ComboBox1.Value.

Try it that way:

If IsDate CDate(Cells(2,13).Value) Then
ComboBox1.Value = Format(CDate(Cells(2,13).Value), "mm/dd/yyyy")
Else
MsgBox "Not a valid date format!"
ComboBox1.SetFocus
End If

Also check if you need to qualify "Cells(2,13)", it isn't clear what
worksheet that is coming from.


HTH,
JP


On Mar 21, 12:46 pm, ryguy7272
wrote:
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