VBA change the font of the first letter only in each cell in a range to a specific font

kcmuppet

Active Member
Joined
Nov 2, 2005
Messages
437
Office Version
  1. 365
Platform
  1. Windows
I'm trying to use the following code to change the font of the first letter only in each cell in a range to a specific font (which is a pie chart font) so that it appears a pie chart and then a value:
VBA Code:
Sub Set_Pie_first_char()
Dim r As Range
With Range("e27:i27")
    For Each r In .Cells
        r.Characters(Start:=1, Length:=1).Font.Name = "Pie charts for maps"
        r.Characters(Start:=2, Length:=6).Font.Name = "Arial Nova"
    Next
End With
End Sub

...but it changes the all the characters in each cell in the range, instead of just the first character.

The values in that range of cells are like this: "e 23.5%"
....produced by formulae like this:
Excel Formula:
=IF($B$25="Overall",
CHAR(CODE("a") + ROUND('Data & Calculations'!BB25*21,1))&" "&TEXT('Data & Calculations'!BB25,"#.0%"),
CHAR(CODE("a") + ROUND('Data & Calculations'!BB26*21,1))&" "&TEXT('Data & Calculations'!BB26,"#.0%"))

How can I adjust the code so that only the first character is the pie chart font?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,215,073
Messages
6,122,975
Members
449,095
Latest member
Mr Hughes

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