Macro para quitar los caracteres extraños y poner acentos y ñ

Esta macro fue generada por ChatGPT y la comparto por este medio:

Sub ReemplazarCaracteres()
    Dim rango As Range
    Set rango = ActiveSheet.UsedRange
    
    'Reemplazar caracteres raros por letras con acento y Ñ
    rango.Replace What:="»A", Replacement:="á", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="É", Replacement:="é", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="Í", Replacement:="í", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="Ó", Replacement:="ó", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="Ú", Replacement:="ú", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="á", Replacement:="á", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="é", Replacement:="é", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="í", Replacement:="í", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="ó", Replacement:="ó", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="ú", Replacement:="ú", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="°", Replacement:="º", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="ª", Replacement:="ª", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="º", Replacement:="º", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="ñ", Replacement:="Ñ", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="ý", Replacement:="ý", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="ü", Replacement:="ü", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="Ñ", Replacement:="Ñ", LookAt:=xlPart, MatchCase:=True
    rango.Replace What:="μ", Replacement:="µ", LookAt:=xlPart, MatchCase:=True
End Sub

Simplemente hay que generar una Macro con este código, seleccionar las columnas que queramos «arreglar», ejecutar la macro y listo.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *