Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 747
Default Seperating Text from Columns

The following assumes the data are in column A starting in cell A2. The macro
doesn't skip blanks:-

Sub Test()
Dim r As Range, c As Range
Dim pos As Integer
Dim x As Integer
Dim txt As String
Dim arr As Variant

Set r = Range(Range("A2"), Range("A2").end(xlDown))

Application.ScreenUpdating = False
For Each c In r.Cells
x = 0
pos = Len(c.Value)
Do
pos = InStrRev(c.Value, " ", pos - 1)
x = x + 1
If pos = 0 Then GoTo skip
Loop Until x = 3
txt = Right(c.Value, Len(c.Value) - pos)
txt = Replace(txt, ",", "")
arr = Split(txt, " ")
txt = Trim(Left(c.Value, pos))
If Right(txt, 1) = "," Then txt = Left(txt, Len(txt) - 1)
c.Value = txt
For x = LBound(arr) To UBound(arr)
c(1, x + 2) = arr(x)
Next
skip:
Next
Application.ScreenUpdating = True
Set r = Nothing: Set c = Nothing
End Sub

Regards,
Greg

"Johnny B" wrote:

Hey guys, i have a confusing question. How would you separate only the last 3
delimited texts into separate columns. For example:

|Column A|
| American Online, 123 Fake Street, California, USA 94224 |

Convert this into:

|Column A| Column B| Column C| Column D|
| American Online, 123 Fake Street | California | USA | 94224 |

Thank you for your time!,

Johnny B

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
Seperating Text from Columns Johnny B[_2_] Excel Discussion (Misc queries) 0 March 28th 07 01:16 AM
seperating values from text enyaw Excel Discussion (Misc queries) 18 January 15th 07 03:49 PM
Seperating text Richard Excel Discussion (Misc queries) 8 June 29th 06 10:21 PM
Seperating cells and columns DRLski Excel Discussion (Misc queries) 3 September 1st 05 06:02 PM
Seperating of Text in one cell into two columns Mistys template Excel Worksheet Functions 1 January 27th 05 04:06 PM


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