Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Split data around a carriage return

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 913
Default Split data around a carriage return

On Fri, 22 Jan 2010 13:10:04 -0800, xp
wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!


If your data is in column A starting on row 1, try this:

In cell B1:
=LEFT(A1,FIND(CHAR(13),A1)-1)

In cell C1:
=RIGHT(A1,LEN(A1)-FIND(CHAR(13),A1))

Copy cells B1:C1 down as far as you have data in column A.

Hope this helps / Lars-Åke
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Split data around a carriage return

DataText to ColumnsDelimited byOther hit CTRL + j and Finish


Gord Dibben MS Excel MVP

On Fri, 22 Jan 2010 13:10:04 -0800, xp wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Split data around a carriage return

Might want to use CHAR(10) instead of 13

Regards,
Peter T


"Lars-Åke Aspelin" wrote in message
...
On Fri, 22 Jan 2010 13:10:04 -0800, xp
wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of
the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!


If your data is in column A starting on row 1, try this:

In cell B1:
=LEFT(A1,FIND(CHAR(13),A1)-1)

In cell C1:
=RIGHT(A1,LEN(A1)-FIND(CHAR(13),A1))

Copy cells B1:C1 down as far as you have data in column A.

Hope this helps / Lars-Åke



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Split data around a carriage return

Data --Text to columns maybe?

"xp" wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!



  #6   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Split data around a carriage return

No...I already tried that...it won't recognize the carriage return to break
on...

Any other ideas?


"Jeff" wrote:

Data --Text to columns maybe?

"xp" wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 149
Default Split data around a carriage return

Xp,

The code below should give you enough code to play around with so that you
can customize it to your situation.

Best,

Matthew Herbert

Sub Testing123()
Dim strSep As String
Dim rngSplit As Range

'Chr(13) or vbCr is the carriage return
'see "Miscellaneous Constants" in VBE Help for more options
strSep = Chr(10)

Set rngSplit = Worksheets(1).Range("A1")

rngSplit.TextToColumns Other:=True, OtherChar:=strSep

End Sub


"xp" wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!

  #8   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Split data around a carriage return

Nice trick! Thanks Gord!

"Gord Dibben" wrote:

DataText to ColumnsDelimited byOther hit CTRL + j and Finish


Gord Dibben MS Excel MVP

On Fri, 22 Jan 2010 13:10:04 -0800, xp wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!


.

  #9   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Split data around a carriage return

Hi,

Thanks for this approach...unfortunately I get "#Value!" error...



"Lars-Ã…ke Aspelin" wrote:

On Fri, 22 Jan 2010 13:10:04 -0800, xp
wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!


If your data is in column A starting on row 1, try this:

In cell B1:
=LEFT(A1,FIND(CHAR(13),A1)-1)

In cell C1:
=RIGHT(A1,LEN(A1)-FIND(CHAR(13),A1))

Copy cells B1:C1 down as far as you have data in column A.

Hope this helps / Lars-Ã…ke
.

  #10   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Split data around a carriage return


I get a value error with either 10 or 13...

"Peter T" wrote:

Might want to use CHAR(10) instead of 13

Regards,
Peter T


"Lars-Ã…ke Aspelin" wrote in message
...
On Fri, 22 Jan 2010 13:10:04 -0800, xp
wrote:

I have a column of data. In each row, is carriage return character in the
middle of some data. The carriage return is never in the same position and
the text is different lengths on each row.

I need to split this data into two columns with the data to the left of
the
carriage return in one column and the data to the right of the carriage
return in another column and leave out the carriage return altogether.

Can anyone help me out with a solution to this? I can code or use formulas
or even a built in command if there is one...thanks!


If your data is in column A starting on row 1, try this:

In cell B1:
=LEFT(A1,FIND(CHAR(13),A1)-1)

In cell C1:
=RIGHT(A1,LEN(A1)-FIND(CHAR(13),A1))

Copy cells B1:C1 down as far as you have data in column A.

Hope this helps / Lars-Ã…ke



.



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Split data around a carriage return

On Fri, 22 Jan 2010 13:55:01 -0800, xp wrote:

No...I already tried that...it won't recognize the carriage return to break
on...

Any other ideas?


If it does not recognize what you are entering as a carriage return, then you
are not entering the same character(s) that are in your string.

Pick your string apart with code like:

A1: Sample string
B1: =MID($A$1,COLUMNS($A:A),1)
B2: =CODE(B1)

Select B1:B2 and fill right until you are into the second line. The code or
codes in between should tell you what your system is using for a carriage
return.
--ron
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
Separating carriage return data into separate cells Richard Excel Discussion (Misc queries) 2 May 11th 09 09:12 PM
Data import, carriage return Sam Excel Programming 1 August 28th 07 11:56 AM
Data import, carriage return Sam Excel Programming 1 August 28th 07 04:22 AM
Carriage return symbol - how to split columns at RealGomer Excel Discussion (Misc queries) 6 February 17th 07 02:34 AM
Importing data to excel (newline/carriage return issue) Tandaina Excel Discussion (Misc queries) 7 September 1st 06 03:16 AM


All times are GMT +1. The time now is 03:47 PM.

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

About Us

"It's about Microsoft Excel"