View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_4_] Bob Phillips[_4_] is offline
external usenet poster
 
Posts: 834
Default Problems with date formats

That is a VBA 'feature', it only knows US dates.

Cast it

CDate(TextBox1.Text)

HTH

Bob

"Vagabond" wrote in message
...
My personal gremlin seems to be that,for no apparent reason (although I am
sure there must be one) when moving dates around in VBA they change from
UK
format to US format. A date I pick up from, say, a text box as 12/01/2010
(being 12th Jan) will arrive in the prescribed cell as 01/12/2010.

I seem to have tried everything including assigning the date to a variable
using the datevar = format([Date from text box], "dd/mm/yyyy") in an
attempt
to force it to behave. Nothing seems to work consistently.

I am using Excel 07 and my machine locale setting is UK.

I am sure that I must be missing a trick but I'm not sure what. Any
ideas,
anyone?