Excel how to replace using wildcard character

microsoft excel

in the excel, I have data like

Series_post
Series_get

I want to find and replace it to

<Series_post>
<Series_get>

I tried

find: Series*
replace: <Series*>

But it doesn't really work. It can find the cells, but replace them with <Series*> all the time.

Best Answer

That type of replace is not a standard functionality in Excel but is do able using VBA:

Sub wrap_in_tag()

    With ActiveSheet.Cells

        Dim c As Variant, firstAddress As String, sFind As String

        sFind = InputBox("Enter search critera, e.g. Series* will result <Series_test>:" _
        , "Enter Critera")

        If sFind = "" Then Exit Sub

        Set c = .Find(sFind, LookAt:=xlWhole)

        If Not c Is Nothing Then
            firstAddress = c.Address
            Do
                c.Value = "<" & c & ">"
                Set c = .Find(sFind, LookAt:=xlWhole)
            Loop While Not c Is Nothing
        End If
    End With
End Sub
Related Question