I need to split the text contents of some cells into multiple columns.
The text inside the cells doesn't follow a precise pattern (e.g. a comma, semicolon...) but the pieces of text are separated by multiple blank spaces. Here is an example:
Hi my name is Andrea (multiple blank spaces) I am good (multiple blank spaces) What about you?
I would like to split my text into three columns (one containing Hi my name is Andrea, the second containing I am good …).
The blank spaces between the sentences are not always the same (e.g. between Andrea and I am good there are 5 blank spaces while between good and what about you there are 7 blank spaces).
I thought that splitting the text when meeting more than one blank space could be a good idea. This is the code I tried:
Sub NameSplit()
Dim txt As String
Dim i As Integer
Dim FullName As Variant
Dim x As String, cell As Range
txt = ActiveCell.Value
FullName = Split(txt, " ")
For i = 0 To UBound(FullName)
Cells(1, i + 1).Value = FullName(i)
Next i
End Sub


Trim$()otherwise you will have left over spaces if there are a odd number of spaces. - Pᴇʜ