1
I have a problem, I took right here a script to enter the ninth digit if the phone starts with 6,7,8,9..
Function ValidarCelular(Myrange As Range) As String
On Error GoTo ErrHandler:
Dim regEx As New RegExp
Dim strPattern As String
Dim strInput As String
Dim strReplace As String
Dim strOutput As String
strPattern = "^[6|7|8|9](?:\d{7}|\d{3}-\d{4})$"
If strPattern <> "" Then
strInput = Trim(Myrange.Value)
strReplace = "9" & strInput
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.test(strInput) Then
ValidarCelular = regEx.Replace(strInput, strReplace)
Else
ValidarCelular = Myrange.Value
End If
End If
Exit Function
ErrHandler:
' Tratamento de Erro
ValidarCelular= CVErr(xlErrNA)
On Error GoTo 0
End Function
However I need the function to skip the first two digits (the DDD) and check the number from the third digit, someone knows how to do this?