williamsabbie
New Member
- Joined
- Feb 27, 2015
- Messages
- 3
Hi Guys & Girls,
I know there are a number of ways of splitting names by space, but i want to ignore the 2nd space.
So if the name is John Fred Bloggs.
I want it to be
[TABLE="width: 50"]
<tbody>[TR]
[TD]John
[/TD]
[TD]Fred Bloggs
[/TD]
[/TR]
</tbody>[/TABLE]
I have 2 macros built- one is a text to columns and the other is below. But both split into 3 or 4, rather than just 2 like i want.
Sub Split_Space()
Dim cell As Range
Dim cell1 As Range
Dim i As Long
Dim J As Long
Dim K As Long
Dim lngFindCol As Long
Dim lngFindCol1 As Long
Dim VarSplitString As Variant
Dim VarSplitString1 As Variant
Dim strContainer As String
Dim strContainer1 As String
i = 1
For Each cell In Range("c1:c" & Sheet1.Range("c" & Rows.Count).End(xlUp).Row)
VarSplitString = Split(cell.Value, " ")
For J = 1 To UBound(VarSplitString)
Sheet1.Cells(i, J + 4) = VarSplitString(J)
Next
i = i + 1
Next cell
i = 1
For Each cell In Range("c1:c" & Sheet1.Range("c" & Rows.Count).End(xlUp).Row)
VarSplitString = Split(cell.Value, " ")
For J = 1 To UBound(VarSplitString)
Sheet1.Cells(i, J + 3) = VarSplitString(K)
Next
i = i + 1
Next cell
End Sub
I know there are a number of ways of splitting names by space, but i want to ignore the 2nd space.
So if the name is John Fred Bloggs.
I want it to be
[TABLE="width: 50"]
<tbody>[TR]
[TD]John
[/TD]
[TD]Fred Bloggs
[/TD]
[/TR]
</tbody>[/TABLE]
I have 2 macros built- one is a text to columns and the other is below. But both split into 3 or 4, rather than just 2 like i want.
Sub Split_Space()
Dim cell As Range
Dim cell1 As Range
Dim i As Long
Dim J As Long
Dim K As Long
Dim lngFindCol As Long
Dim lngFindCol1 As Long
Dim VarSplitString As Variant
Dim VarSplitString1 As Variant
Dim strContainer As String
Dim strContainer1 As String
i = 1
For Each cell In Range("c1:c" & Sheet1.Range("c" & Rows.Count).End(xlUp).Row)
VarSplitString = Split(cell.Value, " ")
For J = 1 To UBound(VarSplitString)
Sheet1.Cells(i, J + 4) = VarSplitString(J)
Next
i = i + 1
Next cell
i = 1
For Each cell In Range("c1:c" & Sheet1.Range("c" & Rows.Count).End(xlUp).Row)
VarSplitString = Split(cell.Value, " ")
For J = 1 To UBound(VarSplitString)
Sheet1.Cells(i, J + 3) = VarSplitString(K)
Next
i = i + 1
Next cell
End Sub