View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Excel is changing date format incorrectly

Hi,

Am Fri, 28 Nov 2014 06:58:20 -0800 (PST) schrieb Khuli:

Unfortunately my data originates from SQL and is being returned as a text string, so DateSerial is not an option.
It seems bizarre (to me) that Excel does not use my regional settings as a default format for dates.


your worksheets and bools have your settings. But VBA works with US
standards.
Try that workaround:

Sub Test()
With Range("A1")
.NumberFormat = "@"
.Value = "01/09/2014"
End With
Columns("A:A").TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(0, 4), TrailingMinusNumbers:=True
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional