Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date format when using combo box

I am using a combo box to fill in data in a spreadsheet.

One part of the data is the date. I have set the required
cells to the following format dd/mm/yy, but when a date is
input via the combo box sometimes the month and date are
swapped around, eg 11/05/03 (11th May 03) is interpretted
as 05/11/03 (5th Nov 03). other dates eg 23/06/03 are
interpretted correctly.

My Control Panel setting are set for the UK.

Also, I want to only allow input in this box as a date
format. if it is not recognised as a date eg 56/85/09 it
will ask for another input.

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Date format when using combo box

Excel is US centric, so in most cases, if it can interpret a date as US
format, it will.

Cdate will observer your regional settings, so you need to convert your date
string to a date serial with Cdate

Dim dtVal as Date
Dim sStr as String

dtVal = 0
Do
sStr = InputBox("Enter Date")
Loop Until isdate(sStr) or sStr = ""
if sSTr = "" then exit sub
dtVal = cDate(sStr)
' or

Range("A1").Value = cDate(sStr)
Range("A1").NumberFormat = "dd/mm/yyyy"

--
Regards,
Tom Ogilvy



"Mikey May" wrote in message
...
I am using a combo box to fill in data in a spreadsheet.

One part of the data is the date. I have set the required
cells to the following format dd/mm/yy, but when a date is
input via the combo box sometimes the month and date are
swapped around, eg 11/05/03 (11th May 03) is interpretted
as 05/11/03 (5th Nov 03). other dates eg 23/06/03 are
interpretted correctly.

My Control Panel setting are set for the UK.

Also, I want to only allow input in this box as a date
format. if it is not recognised as a date eg 56/85/09 it
will ask for another input.

Any ideas?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
permanent conversion of 1904 date format to 1900 date format Jos Excel Worksheet Functions 4 November 26th 15 02:48 PM
Format a combo box to show mmm-yyyy format Gai Excel Discussion (Misc queries) 1 March 7th 07 03:06 AM
format combo box enyaw Excel Discussion (Misc queries) 1 October 27th 06 03:32 PM
I want my combo box to return a date format instead of a number? Cainman Excel Discussion (Misc queries) 2 June 23rd 06 09:29 PM
keep date format in a Combo box t killion Excel Worksheet Functions 1 September 9th 05 05:05 PM


All times are GMT +1. The time now is 02:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"