View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default RegEx Check password string

Also maybe just try [A-Za-z0-9]{7,15}

Tim


"Tim Williams" <saxifrax at pacbell dot net wrote in message
...
EM,

Any reason you're testing the range's Formula instead of the Value ?

Tim

"ExcelMonkey" wrote in message
...
Can someone tell me why this is not working. I am trying to test a
string to
see if it has a combination of letters and numbers from 7-15 characters
long.

Thanks

Public Function CheckPassword(rng As Range) As Variant
Dim reg As Object
'Checks for password with
Set reg = CreateObject("VBScript.RegExp")
With reg
.Pattern = "^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{7,15}$"
CheckPassword = .test(rng.Formula)
End With
End Function