JohnExcel222
New Member
- Joined
- Dec 19, 2018
- Messages
- 35
- Office Version
- 365
Hi there, this code splits the text and numbers into 2 columns. How can I preserve the spaces between the numbers?
Example
If the string contains: Word 2007 Excel 2016...
I would like to get Word Excel in one column and 2007 2016 in another column (and not 20072016)
Example
If the string contains: Word 2007 Excel 2016...
I would like to get Word Excel in one column and 2007 2016 in another column (and not 20072016)
Public Function SplitText(pWorkRng As Range, pIsNumber As Boolean) As String |
Dim xLen As Long |
Dim xStr As String |
xLen = VBA.Len(pWorkRng.Value) |
For i = 1 To xLen |
xStr = VBA.Mid(pWorkRng.Value, i, 1) |
If ((VBA.IsNumeric(xStr) And pIsNumber) Or (Not (VBA.IsNumeric(xStr)) And Not (pIsNumber))) Then |
SplitText = SplitText + xStr |
End If |
Next |
End Function |