Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default convert US date format to Excel readable

Hi! I often import data from other programs to Excel and often the date
formats of those files is of a type that Excel does not understand. Normally
they look like this 12/31/2012 (ie mm/dd/yyyy). now i want to be able to
convert these dates to excel readable dates. i can do this choosing text to
columns and then do some stuff but that takes some time if there are many
series. Is there any way I can write a macro that does this for me? any idea
on how to do that? Thanks alot for your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default convert US date format to Excel readable

Do those steps in Excel with the macro recorder on, that will supply the
code.

--
__________________________________
HTH

Bob

"Arne Hegefors" wrote in message
...
Hi! I often import data from other programs to Excel and often the date
formats of those files is of a type that Excel does not understand.
Normally
they look like this 12/31/2012 (ie mm/dd/yyyy). now i want to be able to
convert these dates to excel readable dates. i can do this choosing text
to
columns and then do some stuff but that takes some time if there are many
series. Is there any way I can write a macro that does this for me? any
idea
on how to do that? Thanks alot for your help!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default convert US date format to Excel readable

Hi Bob. Thanks for your comment! I did record a macro and some adjustments
but I have few problems. When I record the macro the start of the range where
the data is to be plotted is fixed (the first line in my code
...:=Range("A1"). ) Laso I want to be able how long the selection is form the
beginning so that I can adjust the loops. please see my code below. thanks

Sub Makro3()

Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=True,
OtherChar:= _
"/", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
TrailingMinusNumbers:=True


Dim i As Long 'number of rows
Dim j As Long 'number of columns

For j = 0 To 2 'loop columns
For i = 0 To 10 'loop rows
If Range("a1").Offset(i, j) < 10 Then
Range("a1").Offset(i, j).NumberFormat = "@"
Range("a1").Offset(i, j).NumberFormat = "@"
Range("a1").Offset(i, j) = 0 & Range("a1").Offset(i, j)
End If
Next
Next

For i = 0 To 10
Range("a1").Offset(i, 0) = Range("a1").Offset(i, 2) &
Range("a1").Offset(i, 1) & Range("a1").Offset(i, 0)
Next


End Sub



"Bob Phillips" skrev:

Do those steps in Excel with the macro recorder on, that will supply the
code.

--
__________________________________
HTH

Bob

"Arne Hegefors" wrote in message
...
Hi! I often import data from other programs to Excel and often the date
formats of those files is of a type that Excel does not understand.
Normally
they look like this 12/31/2012 (ie mm/dd/yyyy). now i want to be able to
convert these dates to excel readable dates. i can do this choosing text
to
columns and then do some stuff but that takes some time if there are many
series. Is there any way I can write a macro that does this for me? any
idea
on how to do that? Thanks alot for your help!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default convert US date format to Excel readable

Sorry Arne, it is not quite clear to me.

If you select the whole columns doesn't that code work fine? You seem to be
saying that you need to know the last row, but why?

--
__________________________________
HTH

Bob

"Arne Hegefors" wrote in message
...
Hi Bob. Thanks for your comment! I did record a macro and some adjustments
but I have few problems. When I record the macro the start of the range
where
the data is to be plotted is fixed (the first line in my code
..:=Range("A1"). ) Laso I want to be able how long the selection is form
the
beginning so that I can adjust the loops. please see my code below. thanks

Sub Makro3()

Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True,
Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=True,
OtherChar:= _
"/", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
TrailingMinusNumbers:=True


Dim i As Long 'number of rows
Dim j As Long 'number of columns

For j = 0 To 2 'loop columns
For i = 0 To 10 'loop rows
If Range("a1").Offset(i, j) < 10 Then
Range("a1").Offset(i, j).NumberFormat = "@"
Range("a1").Offset(i, j).NumberFormat = "@"
Range("a1").Offset(i, j) = 0 & Range("a1").Offset(i, j)
End If
Next
Next

For i = 0 To 10
Range("a1").Offset(i, 0) = Range("a1").Offset(i, 2) &
Range("a1").Offset(i, 1) & Range("a1").Offset(i, 0)
Next


End Sub



"Bob Phillips" skrev:

Do those steps in Excel with the macro recorder on, that will supply the
code.

--
__________________________________
HTH

Bob

"Arne Hegefors" wrote in message
...
Hi! I often import data from other programs to Excel and often the date
formats of those files is of a type that Excel does not understand.
Normally
they look like this 12/31/2012 (ie mm/dd/yyyy). now i want to be able
to
convert these dates to excel readable dates. i can do this choosing
text
to
columns and then do some stuff but that takes some time if there are
many
series. Is there any way I can write a macro that does this for me? any
idea
on how to do that? Thanks alot for your help!






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
how do I convert utc to a readable time format? Jon Excel Discussion (Misc queries) 2 June 8th 06 02:40 PM
Convert Unix timestamp to Readable Date/time Emily Excel Worksheet Functions 2 January 26th 06 11:59 PM
Convert an Excel date to a date of my format in VBA Sunnous Excel Programming 1 November 15th 05 04:40 PM
How can I convert a date format to an ISO week format (in EXCEL)? ELI Excel Discussion (Misc queries) 2 July 6th 05 06:31 PM
converting PDF file to readable excel format TNMAN Excel Worksheet Functions 1 April 28th 05 01:06 AM


All times are GMT +1. The time now is 01:18 PM.

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

About Us

"It's about Microsoft Excel"