Private Sub simpleRegex()
Dim strPattern As String: strPattern = "^[0-9]{1,2}"
Dim strReplace As String: strReplace = ""
Dim regEx As New RegExp
Dim strInput As String
Dim Myrange As Range
Set Myrange = ActiveSheet.Range("A1")
If strPattern <> "" Then
strInput = Myrange.Value
strReplace = ""
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.Test(strInput) Then
MsgBox (regEx.Replace(strInput, strReplace))
Else
MsgBox ("Not matched")
End If
End If
End Sub
Páginas
viernes, 27 de marzo de 2015
VBA Excel: Como utilizar expresiones regulares para encontrar patrones de texto
Excelente explicacion en en este post de StackOverflow:
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario