I am new at Excel macro.
My question is how to create a macro to find CHAR(219) and CHAR(220) in the sheet, then change its font to Wingding 3.
I don't need to change font color or size etc.
Sub SpecialChar()
Dim strPatt As String
Dim cel As Range
Dim regEx As Object
strPatt = "[ÜÛ]" 'change pattern as needed
Set regEx = CreateObject("VBScript.RegExp")
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = True
.Pattern = strPatt
End With
For Each cel In Range("A:ZZ").End(xlUp).Row).Cells 'change column as needed
If regEx.Test(cel.Text) Then
cel.font.Name = "Wingding 3"
End If
Next cel
End Sub
CodePudding user response:
The font is 'Wingdings 3', not 'Wingding 3'; this should work:
Public Sub ChangeThem()
Dim cel As Range
For Each cel In ActiveSheet.UsedRange
If cel = Chr(219) Or cel = Chr(220) Then
cel.Font.Name = "Wingdings 3"
End If
Next cel
End Sub