Reputation: 161
I have an excel file with a cell which includes a sentence. In this sentence there is a word and i want my cell to be splitted after this word.This word which makes the split should be automatically deleted if it works, if not it can stay.
How can i do this?
Upvotes: 0
Views: 260
Reputation: 96771
Say the word is qwerty. Before:
Select the cells you wish to process and run this short macro:
Sub ytrewq()
Dim qwerty As String, r As Range
Dim v As String
qwerty = " qwerty "
For Each r In Selection
v = r.Text
If InStr(1, v, qwerty) > 0 Then
r.Value = Split(v, qwerty)(0)
r.Offset(0, 1).Value = Split(v, qwerty)(1)
End If
Next r
End Sub
To achieve:
Upvotes: 1