Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining Font Formatting.

Determining Font Formatting

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


1

Oscar has a need to determine the font and font size applied to text in a cell. For instance, if the text in cell A1 is in 12-pt Arial, he would like a function that can be used to return "Arial" in cell B1 and 12 in cell C1.

There is nothing built-in to Excel that will allow this formatting information to be grabbed. You can, however, create a very simple macro that will do the trick. The following macro takes, as arguments, a cell reference and optionally an indicator of what data you want returned.

Function FontInfo1(Rn As Range, Optional iType As Integer = 1) As String
    Select Case iType
        Case 1
            FontInfo1 = Rn.Font.Name
        Case 2
            FontInfo1 = Rn.Font.Size
        Case Else
            FontInfo1 = "Info Not Specified"
    End Select
End Function

You use the function by using a formula such as this in a cell:

=FontInfo1(A1,1)

The second parameter (in this case 1) means that you want the font name. If you change the second parameter to 2 then the font size is returned. If you use some other value for the second parameter, then the function returns the text "Info Not Specified." If you leave the second parameter off entirely, then the function assumes you want the font name and returns that.

If you want to return both values at once, you can apply a lesser-known way of returning arrays of information from a user-defined function. Try the following:

Function FontInfo2(Rn As Range) As Variant
    FontInfo2 = Array(Rn.Font.Name, Rn.Font.Size)
End Function

To use this function, enter the following into a cell:

=FontInfo2(A1)

If you are using Excel 2021 or the version of Excel with Microsoft 365, then the array returned spills into to horizontal cells. (Meaning, if you enter the formula in cell C3, then you end up with values in cells C3:D3.) To use the function in an older version of Excel, just remember to select a range of two cells (such as C3:D3) and press Shift+Ctrl+Enter to enter the function as an array formula.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11358) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Determining Font Formatting.

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

Two-Line Headings in a TOC

If you use the TC field to mark what goes in a TOC, you may wonder why if you mark two lines together with the field they ...

Discover More

Date for Next Wednesday

When working with dates, it is often helpful to be able to calculate some date in the future based on a starting date. ...

Discover More

Copying Headers and Footers

Need to copy headers and footers from one worksheet to another? How about from one workbook to another? Here are some ...

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)

Filling a Cell

One way you can format a cell is so that its contents are repeated over and over again for the entire width of the cell. ...

Discover More

Using Fractional Number Formats

If you want information to display on the screen using fractions instead of decimals, you're in luck. Excel provides ...

Discover More

Converting From Numbers to Text

If you have a range of numeric values in your worksheet, you may want to change them from numbers to text values. Here's ...

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 less than 3?

2024-04-13 16:27:57

J. Woolley

The old Excel 4 macro function GET.CELL can return a cell's font name and size. A formula with GET.CELL cannot be used in modern versions of Excel, but it is possible to use an Excel defined name that returns a GET.CELL result.

Click Formulas > Defined Names > Define Name (Alt+M+M+D) and enter
Name: FontNameCellLeftOne
Comment: Return font name for cell located one column to the left.
Refers To: =GET.CELL(18,INDIRECT("R[0]C[-1]",FALSE))

Repeat Formulas > Defined Names > Define Name (Alt+M+M+D) and enter
Name: FontSizeCellLeftTwo
Comment: Return font size for cell located two columns to the left.
Refers To: =GET.CELL(19,INDIRECT("R[0]C[-2]",FALSE))

If Oscar's text in cell A1 is in 12-pt Arial, the following formula in cell B1 will return Arial as text
    =FontNameCellLeftOne
and the following formula in cell C1 will return 12 as numeric
    =FontSizeCellLeftTwo

My Excel Toolbox includes the EvaluateExcel4Macro macro to evaluate and display the result of an Excel 4 macro function with an option to put the result into a cell. The EvaluateExcel4Macro macro accepts an Excel 4 macro function as text, but cell references must be in R1C1 style. Cell A1 of the active sheet is equivalent to !R1C1. See https://excelribbon.tips.net/T008803
Therefore, this Excel 4 macro function returns the font name for cell A1
    GET.CELL(18,!R1C1)
and this Excel 4 macro function returns the font size for cell A1
    GET.CELL(19,!R1C1)
See https://sites.google.com/view/MyExcelToolbox/
For more on Excel 4 macro functions, see
https://exceloffthegrid.com/using-excel-4-macro-functions/


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.