View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Matthew Herbert[_3_] Matthew Herbert[_3_] is offline
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!