Yigit Tanverdi
Yigit Tanverdi

Reputation: 161

splitting a cell starting from a specific word in excel

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

Answers (1)

Gary's Student
Gary's Student

Reputation: 96771

Say the word is qwerty. Before:

enter image description here

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:

enter image description here

Upvotes: 1

Related Questions