Home » excel » Excel: How do I replace text by using a wildcard?

Excel: How do I replace text by using a wildcard?

Posted by: admin April 23, 2020 Leave a comment


A1= Blabla,124814012

I want to remove everything but “Blabla”.

What command do i use to get the effect as if i did CTRL+H (replace) and told it to replace “,*” with nothing.

I can do it this:

But need to be able to do it using x* etc.

How to&Answers:

get Morefunc Addon and use:

=REGEX.SUBSTITUTE(A1 , ",(.*)" , "")




Dim x as string
x = range("a1").value
if cbool(instr(1, x, chr(44))) then _
    x = left(x, instr(1, x, chr(44))-1)  'Chr(44) is a comma
debug.print x

Addendum: I’d make the function version a little fancier.

Public Function fc_Split_at(sSTR As String, sDELIM As String, Optional iPC = 1)
    fc_Split_at = Split(sSTR, sDELIM)(iPC - 1)
End Function


=fc_Split_at(<original string>, <delimiter>, [optional]<piece to return>)

?fc_Split_at("*Blabla,124814012", ",")
?fc_Split_at("*Blabla,124814012", ",", 2)


Excel’s Find & Replace does allow for wildcard characters.

In your simplified example, if you went to find / replace and typed in:

Find What: Blabla*

Replace With: Blabla

That would do the trick and remove anything following Blabla.

Hope that does the trick!!