We help IT Professionals succeed at work.
Get Started

VBA Script to change font (size&style) for specific text in document

78 Views
Last Modified: 2020-02-07
All my Catalog Excel files have 3 different font styles.
1. Title of Products - this is Blue text font size 11.5
2. under that (#1 Title of Products) is Bold Text and underlined font size 9
3. then is a list of part#'s font size 9 regular text

Currently the font is Helvetica for all of them but I need to change font. I can select the whole doc and change the font but I also need to update the font sizes for each of the above 1. 2, and 3 types of text in my doc. I am using Mac Excel and it does have the same Find Tool as on a PC so I need a VBA script to do this.

I Recorded a Macro but this requires me to manually select each type of row. I need the VBA script to be able to find each of the 1, 2, and 3 above and change font style.

Here is a sample of what the Macro recorded when changing the #1 Title of Products manually.

Sub fontchange()
'
' fontchange Macro
'

'
    Rows("8:8").Select
    With Selection.Font
        .Name = "MuktaMahee Bold"
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With Selection.Font
        .Name = "MuktaMahee Bold"
        .Size = 11.5
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
End Sub

Screen-Shot-2020-02-06-at-9.15.12-PM.jpgTomlinson.xls
Comment
Watch Question
Mechanical Engineer
CERTIFIED EXPERT
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 3 Answers and 16 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE