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.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
It's easy to automatically set the contents of one cell to be equal to another cell. But what if you want to copy the ...
Discover MoreYou can use the Paste Special feature in Excel to multiply the values in a range of cells. If you don't want Excel to ...
Discover MoreWhen adjusting column width, Excel can add an extra line to some cells. This behavior seems to be related to the text ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments