View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default I want to separate text at all the full stops

One way:

Public Sub FullStopDelmitedTextToRows()
Const csDelim As String = "."
Dim vArr As Variant
Dim rCell As Range
With Selection
If .Rows.Count 1 Then
MsgBox "You must choose cells in one row only"
Else
For Each rCell In .Cells
With rCell
If Not IsEmpty(.Value) Then
vArr = Split(.Text, csDelim)
If IsArray(vArr) Then
With .Resize(UBound(vArr) - LBound(vArr) + 1, 1)
If Application.CountA(.Cells) 1 Then
MsgBox "Can only expand into empty cells"
Exit Sub
End If
.Value = Application.Transpose(vArr)
End With
Else
.Value = vArr
End If
End If
End With
Next rCell
End If
End With
End Sub

Note: Error checking is very minimal




In article ,
"Michelle" wrote:

I know I can do this with text-to-columns, but I may have more than 256
strings in my text-file seperated by full stops, and I can't always use
2007.

What I need is a kind of 'Text-to-Rows' feature, so that it puts each string
into the next cell down

Is there an easy way to do this?

M