Skip to content

Instantly share code, notes, and snippets.

@chepe263
Last active August 29, 2015 14:11
Show Gist options
  • Save chepe263/40427b0ecc5d22875346 to your computer and use it in GitHub Desktop.
Save chepe263/40427b0ecc5d22875346 to your computer and use it in GitHub Desktop.
VBA-Excel: Buscar si palabra tiene tilde
'http://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops
Sub buscarAcentos()
Dim regEx As New RegExp
Dim strPattern As String: strPattern = "[áéíóúÁÉÍÓÚ]"
Dim Myrange As Range
Dim i As Integer
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
For i = 5 To 124
Set Myrange = ActiveSheet.Range("B" & i)
strInput = Myrange.Value
If regEx.Test(strInput) Then
Range("F" & i).Value = strInput
Range("G" & i).Value = ""
Else
Range("G" & i).Value = strInput
Range("F" & i).Value = ""
End If
Next i
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment