Excel Search function with Regular Expressions (Excel Regex Find)

Just copy and paste in VBA Editor:

Function RegExpFind(text_string As String, pattern As String) As String
    Dim regEx As Object
    Set regEx = CreateObject("VBScript.RegExp")
    
    With regEx
        .Pattern = pattern
        .IgnoreCase = True
        .Global = False
    End With
    
    If regEx.Test(text_string) Then
        RegExpFind = regEx.Execute(text_string)(0)
    Else
        RegExpFind = ""
    End If
End Function

Sample usage:

=RegExpFind(A1;"[\d.]+x[\d.]+")

Share and Enjoy !

Shares