Date Format

  • Thread starter Thread starter MBlake
  • Start date Start date
M

MBlake

Hi,
I have a combobox displaying a range of available dates in the format
dd/mm/yy. Once selected the date should display in the combobox.
Unfortunately once selected the date displays in numeric. Is there a method
to have the combobox maintain the date format?

Your help is really appreciated.
Mickey
 
Private Sub ComboBox1_Change()
ComboBox1.Value = Format(ComboBox1.Value, "DD/MM/YY")
End Sub
 
Hi Toppers,
Brilliant!, I've been looking at that for a few days and got nowhere. I am
very grateful for your help. Is it now possible to transfer the date
dd/mm/yy to four text boxes day/datemonth/year so that when a user enter the
date, the textboxes change to - for example - Mon/15/Apr/05. Again I can do
this in the worksheet but how do I accomplish it on a user form?

Mickey
 
Hi,

Private Sub ComboBox1_Change()

Weekdays = Array("Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat)

ComboBox1.Value = Format(ComboBox1.Value, "DD/MMM/YY")

myweekday = Weekdays(Weekday(ComboBox1.Value) - 1)

TextBox1.value = myweekday & "/" & ComboBox1.Value
TextBox2.value = myweekday & "/" & ComboBox1.Value
.....

End Sub

HTH
 
Cheers Toppers,
I'm getting a 'variable not defined' error and the line 'Weekdays=Array etc
is highlighted. I'll take a look and see if I can figure it out.

Cheers for your help, very much appreciated,
Mickey
 
You need to declare the variables before you use them. E.g.,

Dim Weekdays As Variant
Dim MyWeekday As Variant


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Sorry about the variable declarations - I hadn't set Option Explicit when I
tested it. Hope it is OK now .. and thank you Chip.
 
Back
Top