View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jan Karel Pieterse Jan Karel Pieterse is offline
external usenet poster
 
Posts: 535
Default UK to US date format

Hi David.Wilson,

Other dates (I guess ones where the day value is bigger than 12), seem
fine. The network and applications at my work are set to UK date
format, so why are these values changing over to US format?


Because VBA speaks American.

To avoid the trouble you have, dim a variable as a Date and deliberately
convert the string of the form's control to a date and put that into the
Date variable:

Sub test()
Dim dDate As Date
Dim sDate As String
sDate = InputBox("Please enter a date")' a string
dDate = CDate(sDate) 'Now convert string to Date, using regional
settings
ActiveCell.Value = dDate
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com