Enforcing a Desired Font

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


Bryan has an Excel workbook that is shared in his office. He created the workbook and set the default font, but someone is changing the font. Bryan wonders if he can force the font to his desired font when the workbook is closed.

An easy way to do this is to use the BeforeClose event handler for the workbook. You can have the handler step through each of the worksheets and set the font for all the cells in this manner:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim s As Worksheet

    For Each s In ActiveWorkbook.Sheets
        s.Cells.Font.Name = "Calibri"
    Next
End Sub

This sets the font to Calibri, but you can change the font name, as necessary. If you need to change other font characteristics, you can modify the event handler to do so:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim s As Worksheet

    For Each s In ActiveWorkbook.Sheets
        With s.Cells.Font
            .Name = "Calibri"
            .Size = 10
        End With
    Next
End Sub

You'll want to be careful, though, changing too many font characteristics, as you may end up getting rid of some you want to keep, such as bold or italic.

Remember that these macros should be added to the ThisWorkbook object in the Visual Basic Editor.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (4801) 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

AutoCorrecting for Your Common Errors

AutoCorrect is a great way to correct your spelling, particularly if you misspell the same words over and over. Here's a ...

Discover More

Changing Coordinate Colors

Tired of the default colors that Excel uses to display the row and column coordinates? You can modify the colors, but ...

Discover More

Excluding Some Data from a Chart

Excel is a whiz at creating charts from your worksheet data. When the program tries to determine what should be included ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Rounded Corners on Cells

As you are formatting a worksheet, Excel allows you to easily add borders to cells. Adding rounded corners to cells is a ...

Discover More

Adjusting Cell Margins for More White Space

Is the information in your cells too jammed up? Here are some ways you can add some white space around that information ...

Discover More

Specifying Font Color in a Formula

Do you need to change text color based on the result of a formula? This tip provides a couple of ways you can accomplish ...

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 four minus 0?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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.