Change Font Characters to a Specific Font While Preserving Symbol Font -- Need to Work with Cells That Have Formulas As Well

kagekon

New Member
Joined
Jun 13, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi, I am using this code to change the characters in a cell from one font to another. For example, to change any character that is not "DesiredFont" to that font. I am also excluding the font "Symbol" because I mix a lot of symbols in my cell text. This, however, doesn't work for cells that contain formulas where the result is just a number or a concatenated string. Is there any way to make this work for cells that contain formulas as well (and not mess up my cells that contain mixtures of DesiredFont and Symbol font)?

Thanks!

Sub FormatFonts()

Dim Cl As Range
Dim i As Long

Excel.Application.ScreenUpdating = False

For Each Cl In ThisWorkbook.ActiveSheet.UsedRange.SpecialCells(xlConstants)
For i = 1 To Len(Cl.Value)
If Cl.Characters(i, 1).Font.Name <> Range("DesiredFont").Value And Cl.Characters(i, 1).Font.Name <> "Symbol" Then
Debug.Print Cl.Address
Cl.Characters(i, 1).Font.Name = Range("DesiredFont").Value
End If
Next i
Next Cl

Excel.Application.ScreenUpdating = True

End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top