ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Format (https://www.excelbanter.com/excel-programming/328559-date-format.html)

MBlake

Date Format
 
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



Toppers

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

"MBlake" wrote:

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




MBlake

Date Format
 
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



Toppers

Date Format
 
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

"MBlake" wrote:

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




MBlake

Date Format
 
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


"Toppers" wrote in message
...
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

"MBlake" wrote:

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






Chip Pearson

Date Format
 
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




"MBlake" wrote in message
...
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


"Toppers" wrote in message
...
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

"MBlake" wrote:

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








Toppers

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

"MBlake" wrote:

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


"Toppers" wrote in message
...
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

"MBlake" wrote:

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







MBlake

Date Format
 
Cheers Toppers,
It all works very well,

Mickey




All times are GMT +1. The time now is 04:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com