Date Format Issue

  • Thread starter Thread starter alexm999
  • Start date Start date
A

alexm999

I have a file that exports a date in the following format:
2003.12.30
2004.5.11

Its the year, month and then day. BUt I cannot use cell formating t
change the date format to:
Month/Day/Year

How can I do this using programming.
The data is always in column
 
Alex,

Try something like the following:

Sub AAA()
Dim Y As Integer
Dim M As Integer
Dim D As Integer
Dim Rng As Range
Dim Arr As Variant
For Each Rng In Range("D1:D10") '<<<CHANGE
If Rng.Value <> "" Then
Arr = Split(Rng.Text, ".")
Y = Arr(LBound(Arr))
M = Arr(LBound(Arr) + 1)
D = Arr(LBound(Arr) + 2)
Rng.Value = DateSerial(Y, M, D)
End If
Next Rng
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top