Stopping Fonts from Changing

Written by Allen Wyatt (last updated April 6, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Jim has a macro that creates an invoice in Excel. The invoice uses various fonts for visual appeal, but now the Aptos Narrow font shows up in the invoices, even though Jim's default font for new workbooks is Arial Narrow. He wonders if there is a way to make sure his desired fonts are used instead of what Microsoft thinks he should use.

There could be several factors at play in Jim's situation, and it will take some sleuthing to figure out what is going on. Jim indicates that he has set the default font for new workbooks to be Arial Narrow. When I hear this, to me it means that Jim has set up a special workbook called book.xltx and stored it in the XLSTART folder. However, Jim may have done it differently, having created a template that defines how he wants his invoices to look. Or, he may have simply created a default worksheet (named sheet.xltx) stored in the XLSTART folder.

You get the idea—it is imperative to know how Jim created his "default font" for new workbooks. This is alluded to in this tip:

https://tips.net/T12618

Read the tip, and you find that Excel allows you to define a default font for new workbooks. However, this font setting is ignored completely if you create the special files in your XLSTART folder. Changing the default font setting in Excel does nothing to change whatever fonts you have defined in the book.xltx or

Now, to make it more complicated, you need to figure out how the macro is creating a new workbook. You can do this by creating a very simple macro:

Sub TestWB()
    Workbooks.Add
End Sub

The simple line will create a new workbook. Now you can analyze what it creates to see if it matches what you may have in the book.xltx template or what you specified in the Excel settings. Once that determination is made, you'll be able to figure out what has to change to get the invoice workbook to look the way you want.

This approach, of course, includes an inherent assumption that the .Add method is how Jim's macro also creates a new workbook. If Jim's macro creates a workbook in a different manner, then that needs to be taken into account—change the above macro to create a new workbook using the command that Jim's macro uses, and then do the analysis to determine the basis of the new workbook.

If all else fails, you can create a "cleanup" macro that can be run after the invoice is created. Here's an example of how this could be handled:

Sub keepArialNarrowFont()
    Dim wsh As Worksheet
    Dim rng As Range
    Dim defFontName As String

    For Each wsh In ThisWorkbook.Worksheets
        'Loop through all cells in the worksheet
        For Each rng In wsh.UsedRange
            'Set the font name for each used cell
            If rng.Font.Name = "Aptos Narrow" Then rng.Font.Name = "Arial Narrow"
        Next rng
    Next wsh
End Sub

The macro steps through all the cells in each worksheet in the workbook and, if the font in that cell is Aptos Narrow, changes the font to Arial Narrow.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13916) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Counting Shaded Cells

Ever want to know how many cells in a worksheet (or a selection) are shaded in some way? You can create a handy little ...

Discover More

Adding Leading Zeroes to ZIP Codes

Import a bunch of ZIP Codes into Excel, and you may be surprised that any leading zeroes disappear. Here's a handy little ...

Discover More

Matching At the Beginning or End of a Word

The pattern matching capabilities of Word's search engine are quite powerful. You can tailor your search pattern so that ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Calculating Only the Active Workbook

When you enter information into a workbook, Excel automatically recalculates every worksheet in every open workbook on ...

Discover More

Creating and Naming a Worksheet Using a Macro

You can use macros to make your common Excel tasks easier and faster. For instance, if you routinely need to create new ...

Discover More

Inserting a Page Break Every X Rows

As you format your worksheet, Excel allows you to add page breaks where you'd like. If you want to put in a series of ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 9?

2024-04-06 12:01:35

J. Woolley

Re. the Tip's last macro, I have two nits to pick:
1. Be careful with use of ThisWorkbook, which is a property of the Application object. It refers to the workbook containing the macro, which might be Personal.xlsb, an Excel Add-in (.xlam), or another open workbook. To refer to the active workbook, use ActiveWorkbook instead.
2. I believe there is only one UsedRange in a worksheet; therefore, the macro's second For Each loop is unnecessary.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.