Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Seperating Text from Columns | Excel Discussion (Misc queries) | |||
seperating values from text | Excel Discussion (Misc queries) | |||
Seperating text | Excel Discussion (Misc queries) | |||
Seperating cells and columns | Excel Discussion (Misc queries) | |||
Seperating of Text in one cell into two columns | Excel Worksheet Functions |