Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using Text to columns in a macro


Hi there,

I a have a list of dates which have been imported as MM/DD/YYYY and
am having problems using text to columns in a macro to convert them t
DD/MM/YYYY.

When I do it manually from the data menu it works fine selecting th
data type as Date and MDY.

I can record this and then run the macro and it picks up the date
which are 07/24/05 but ignores the dates which are 08/02/05 (this is
August 05).

This is the script I am using:

Columns("I:I").Select
Selection.TextToColumns Destination:=Range("j1")
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True
Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False
FieldInfo _
:=Array(1, 3)

Can anyone help me?

Thanks
:confused

--
dipp
-----------------------------------------------------------------------
dippy's Profile: http://www.excelforum.com/member.php...fo&userid=2592
View this thread: http://www.excelforum.com/showthread.php?threadid=39291

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default using Text to columns in a macro

Hi Dippy,
I don't the specifics about the text to columns issue.
However, if you need a work around, here is a bit of code that will convert
MM/DD/YYYY to DD/MM/YYYY.

Sub Convert()
Dim Iloop As Integer
Dim Numrows As Integer
Numrows = Range("A65536").End(xlUp).Row
For Iloop = 1 To Numrows
Cells(Iloop, "A") = Mid(Cells(Iloop, "A"), 4, 2) & "/" & _
Left(Cells(Iloop, "A"), 2) & "/" & Right(Cells(Iloop, "A"), 5)
Next Iloop
End Sub

This code assumes that every date is ten characters long and resides in
column A.
You can change the code from column A to the appropriate column reference.
If your date entries vary in length, post back and I will change the code to
allow for that.

HTH
--
Ken Hudson


"dippy" wrote:


Hi there,

I a have a list of dates which have been imported as MM/DD/YYYY and I
am having problems using text to columns in a macro to convert them to
DD/MM/YYYY.

When I do it manually from the data menu it works fine selecting the
data type as Date and MDY.

I can record this and then run the macro and it picks up the dates
which are 07/24/05 but ignores the dates which are 08/02/05 (this is 2
August 05).

This is the script I am using:

Columns("I:I").Select
Selection.TextToColumns Destination:=Range("j1"),
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True,
Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False,
FieldInfo _
:=Array(1, 3)

Can anyone help me?

Thanks



--
dippy
------------------------------------------------------------------------
dippy's Profile: http://www.excelforum.com/member.php...o&userid=25921
View this thread: http://www.excelforum.com/showthread...hreadid=392918


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
Looking to Expand on Text to Columns Macro Jenny B. Excel Discussion (Misc queries) 2 August 30th 07 06:52 PM
Text to columns macro problem Andy Excel Discussion (Misc queries) 4 June 20th 06 02:10 PM
macro to split text in columns nshanmugaraj Excel Discussion (Misc queries) 1 March 3rd 06 02:03 PM
Macro for Text to Columns - convert to text or general goofy11 Excel Programming 1 May 16th 05 03:51 AM
Linking text columns with text and data columns Edd Excel Worksheet Functions 0 March 17th 05 04:23 PM


All times are GMT +1. The time now is 11:37 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"