Macro to find multiple values within a text string of a column then insert tab spacer

Hello experts,

I would like to have a macro that finds a range of specified values within a text string then insert a tab spacer.

For instance, I have rows of data within column A. For every instance of the text string "Text Line" or "Data Info", I would like to insert a tab spacer between the word Text and Line, as well as Data and Info.

Please find attached an example as a illustration.

Could anyone provide some assistance?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
You may try:

Sub Button1_Click()
    r = Cells(Cells.Rows.Count, "A").End(xlUp).Row
    strTab = "          "
    For i = 1 To r
        If Cells(i, "A") Like "*Text Line*" Then
            idx = InStr(Cells(i, "A"), "Text Line")
            Cells(i, "A") = Left(Cells(i, "A"), idx - 1) & "Text " & strTab & Mid(Cells(i, "A"), idx + Len("Text "))
        ElseIf Cells(i, "A") Like "*Data Info*" Then
            idx = InStr(Cells(i, "A"), "Data Info")
            Cells(i, "A") = Left(Cells(i, "A"), idx - 1) & "Data " & strTab & Mid(Cells(i, "A"), idx + Len("Info "))
        End If
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lkirkeAuthor Commented:
Fantastic. Thank you Ryan.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.