PC Review


Reply
Thread Tools Rate Thread

convert US date format to Excel readable

 
 
Arne Hegefors
Guest
Posts: n/a
 
      19th Nov 2008
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      19th Nov 2008
Do those steps in Excel with the macro recorder on, that will supply the
code.

--
__________________________________
HTH

Bob

"Arne Hegefors" <(E-Mail Removed)> wrote in message
news:161F6B9C-26B3-4495-9549-(E-Mail Removed)...
> 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 With Quote
 
Arne Hegefors
Guest
Posts: n/a
 
      19th Nov 2008
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" <(E-Mail Removed)> wrote in message
> news:161F6B9C-26B3-4495-9549-(E-Mail Removed)...
> > 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 With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      19th Nov 2008
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" <(E-Mail Removed)> wrote in message
news:22E8B5F6-EF2C-4C7B-A5E5-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:161F6B9C-26B3-4495-9549-(E-Mail Removed)...
>> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I convert utc to a readable time format? =?Utf-8?B?Sm9u?= Microsoft Excel Misc 2 8th Jun 2006 02:40 PM
Convert Unix timestamp to Readable Date/time =?Utf-8?B?RW1pbHk=?= Microsoft Excel Worksheet Functions 2 26th Jan 2006 11:59 PM
how to convert BLOB DB field to readable format (text) Serge Klokov Microsoft C# .NET 4 25th Jun 2004 11:30 AM
Convert Windows Trace into human readable format Suman Windows XP Drivers 0 22nd Oct 2003 12:24 AM
Convert driver traces to human readable format Suman Windows XP New Users 0 17th Oct 2003 06:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:22 AM.