Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using like to compare to a string in excel [duplicate]

What I want to match is this regex: ^[a-zA-Z]{2}[0-9]{10}$

For example, how can I test whether the contents of E2 are like [A-Za-z][A-Za-z]##########, and can I wrap that into an IF statement?

like image 730
user2051347 Avatar asked Dec 06 '25 05:12

user2051347


1 Answers

Use this:

Function regxMatch(Value As String, Pattern As String, Optional IgnoreCase As Boolean = False)
    Dim r As New VBScript_RegExp_55.RegExp
    r.Pattern = Pattern
    r.IgnoreCase = IgnoreCase
    If r.Test(Value) Then
        M = "Matches '" & Pattern & "'"
    Else
        M = ""
    End If
End Function

Function should be self explanatory!

like image 139
Carol.Kar Avatar answered Dec 08 '25 20:12

Carol.Kar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!