Date Format

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
 
G

Guest

Private Sub ComboBox1_Change()
ComboBox1.Value = Format(ComboBox1.Value, "DD/MM/YY")
End Sub
 
M

MBlake

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
 
G

Guest

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
 
M

MBlake

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
 
C

Chip Pearson

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
 
G

Guest

Sorry about the variable declarations - I hadn't set Option Explicit when I
tested it. Hope it is OK now .. and thank you Chip.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top