Mimicking Small Caps in Excel

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


2

Conrad would like to mimic the "small caps" capability of Word within Excel. The only way he can think to do this is to develop a macro that steps through every character in a cell. If the character is lowercase and 11 pt, then the macro should change the character to uppercase 9 pt. If the character is uppercase (or not a letter), then it should not be affected. Problem is, Conrad doesn't know how to affect the formatting of individual characters in the cell in the manner described.

When using a macro to affect only certain characters within the cell, it is good to remember that each cell has its own Characters collection that can be accessed and modified. Each element in the collection represents, as you might expect, a single character in the cell.

This allows us to put together a macro that examines what is currently in the cell, and if the character is currently lowercase, convert just that character to uppercase and reduce that character's font size.

Sub SmallCaps()
    Dim rCell As Range
    Dim sWords As String
    Dim sCharacter As String
    Dim x As Long

    'go through each cell in selection
    For Each rCell In Selection
        'Don't want to work on formulas
        If Not rCell.HasFormula Then
            sWords = rCell.Value 'Get the cell contents
            For x = 1 To Len(sWords) 'Act on each letter
                sCharacter = Mid(sWords, x, 1)
                If sCharacter >= "a" And sCharacter <= "z" Then
                    'sCharacter is a lowercase letter
                    With rCell.Characters(Start:=x, Length:=1)
                        'Decrease the font size by 2
                        .Font.Size = .Font.Size - 2
                        'Make character uppercase
                        .Text = UCase(sCharacter)
                    End With
                End If
            Next
        End If
    Next
End Sub

This macro does its work on whatever cells are selected when it is run. It checks to make sure the cell doesn't contain a formula (formulas are skipped), and then it makes any modification to lowercase characters in the cell.

There are drawbacks to using a macro such as this, and you should be aware of them. The biggest drawback is that it actually modifies what is in the cells. When it is done, the cells will contain all uppercase text, even though the formatting may make it look like small caps. This means that you may have problems when you later run the macro a second time, and Excel's proofing tools (such as the spell checker) won't work on words that are all uppercase. (Excel can, however, be configured to still spell check such words.)

Because of the drawbacks, you may want to take an entirely different approach—change the font you use for the cells in which you want small caps. If you search the web for a "small caps fonts" (without the quote marks) you should be able to find many candidates, and a good number of them are available for free. Here is one site that may have something you like:

https://www.fontsquirrel.com/fonts/list/tag/small%20caps

Just download the font you want (from this or any other reputable source) and install it on your system. When you restart Excel, the font should be available for formatting cells. Cells formatted to use such a font would show text as small caps, even though the actual cell contents are a mixture of upper- and lowercase.

One thing to be aware of if you go the route of using a small-caps font: If you share the workbook with someone who doesn't have that font installed on their system, there may be problems. The workbook won't be "hurt" in any way, but the information in the workbook will probably not display correctly as Excel will substitute a default font in place of the one you chose.

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

Smoothing Out Data Series

One way you can make your charts look more understandable is by removing the "jaggies" that are inherent to line charts. ...

Discover More

Changing the Format of Existing Dates

There are a myriad of ways in which a date can be formatted--day first, month first, number of digits in the year, etc. ...

Discover More

Selecting a Graphic Behind a Text Box

How to select a graphic that is obscured by a text box can be perplexing. Here's an overview of the different ways you ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Setting Cell Width and Height Using the Keyboard

Hate to take your hands off the keyboard? Here are a couple of ways you can reject the mouse and still adjust the height ...

Discover More

Changing the Percent Symbol

Some symbols can be easily changed in Excel or in Windows, such as the symbols used for currency and to separate ...

Discover More

Changing Currency Formatting for a Single Workbook

Currency is formatted differently in different corners of the world. Most formatting uses periods and commas to indicate ...

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 six minus 6?

2023-03-11 15:13:36

J. Woolley

The following macros in My Excel Toolbox have been updated to support Undo (Ctrl+Z) similar to the TextSmallCaps macro described in my previous comment below: TextLowerCase, TextUpperCase, TextProperCase, TextTitleCase, TextToNumber, TextFromNumber, TextTrim, and TextClean.
See https://sites.google.com/view/MyExcelToolbox/


2023-03-06 17:54:35

J. Woolley

Inspired by this Tip, the TextSmallCaps macro was added to My Excel Toolbox. Unlike the Tip's macro, TextSmallCaps supports Undo (Ctrl+Z). Here is an abbreviated version.

Public Sub TextSmallCaps()
    Const myName As String = "TextSmallCaps"
    TextSmallCaps_Undo False
    Application.OnUndo ("Undo " & myName), _
        (ThisWorkbook.Name & "!" & myName & "_Undo")
End Sub

Private Sub TextSmallCaps_Undo(Optional Undo As Boolean = True)
    Static rText As Range, sSave() As String
    Dim rCell As Range, sText As String, sChar As String
    Dim nSave As Long, n As Integer
    Const nSub As Integer = 2
    If Not Undo Then
        Set rText = Selection.SpecialCells(xlCellTypeConstants, xlTextValues)
        Set rText = Intersect(Selection, rText) 'in case single cell selected
        If rText Is Nothing Then Exit Sub
        ReDim sSave(1 To rText.Cells.Count)
    End If
    rText.Select
    nSave = 0 'unnecessary
    For Each rCell In rText
        With rCell
            nSave = nSave + 1
            If Undo Then
                sText = sSave(nSave)
            Else
                sText = .Value
                sSave(nSave) = sText
            End If
            If Not IsNumeric(sText) Then
                For n = 1 To Len(sText)
                    sChar = Mid(sText, n, 1)
                    If sChar >= "a" And sChar <= "z" Then
                        With .Characters(n, 1)
                            If Undo Then
                                .Text = sChar
                                .Font.Size = .Font.Size + nSub
                            Else
                                .Text = UCase(sChar)
                                .Font.Size = .Font.Size - nSub
                            End If
                        End With
                    End If
                Next n
            End If
        End With
    Next rCell
End Sub

See https://sites.google.com/view/MyExcelToolbox/


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.