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: Deleting Unwanted Styles.

Deleting Unwanted Styles

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


1

When you work with other people who use Excel, it is not unusual to copy worksheets from their workbooks into your own workbook. When you do so, the worksheet isn't the only thing that is copied—Excel also copies their formatting styles to your workbook. Manually deleting the unwanted styles can be a hassle, depending on the number of styles. Removing user-defined styles is very easy, though, if you use a macro. The following macro will quickly delete the unwanted styles:

Sub StyleKill()
    Dim styT As Style
    Dim intRet As Integer

    For Each styT In ActiveWorkbook.Styles
        If Not styT.BuiltIn Then
            intRet = MsgBox("Delete style '" & styT.Name & "'?", vbYesNo)
            If intRet = vbYes Then styT.Delete
        End If
    Next styT
End Sub

The macro needs just a little user input. Whenever the macro detects a user-defined style, you are asked if you want to delete it. Clicking on the Yes button causes the style to be removed from the workbook.

You should be aware of the limitations of a macro approach such as this. The biggest limitation is that if your workbook is corrupted in any way (and, yes, it is very possible to have corruption in the styles in a workbook), this macro won't fix that corruption. Instead, you may want to look at a handy third-party solution (XLStylesTool) that can work wonders if you need to clean up your styles in a more comprehensive manner. You can find more information about XLStylesTool here:

https://apps.microsoft.com/store/detail/xlstylestool/9WZDNCRFJPTG

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 (12259) 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: Deleting Unwanted Styles.

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

Merge and Center Not Available

What are you to do if you are trying to format a worksheet, only to find out that one of the tools you need is not ...

Discover More

Inserting a Picture in Your Worksheet

Worksheets can contain more than just text and numbers. Here's the low-down on the different types of pictures you can ...

Discover More

Limiting Lines in a Table Cell

When creating tables, Word automatically sets the size of the cells. But what if you want to make sure each cell is a ...

Discover More

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!

More ExcelTips (ribbon)

Understanding Underlines

Excel provides a variety of underlining styles you can use when you need to underline information within a cell. Here's ...

Discover More

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 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 two more than 7?

2023-01-22 10:28:35

J. Woolley

My Excel Toolbox includes the following dynamic array function to return all styles for the formula cell's workbook:
=ListStyles([SkipHeader])
Expect 2 columns (Name, Built-in), where Built-in is FALSE for a user-defined style. Here is an abbreviated version:

Function ListStyles()
    Dim oWB As Workbook, A() As Variant
    Dim nRows As Long, n As Long
    Set oWB = Application.Caller.Parent.Parent
    nRows = oWB.Styles.Count
    If nRows = 0 Then
        ListStyles = "No Styles"
        Exit Function
    End If
    ReDim A(1 To nRows, 1 To 2)
    For n = 1 To nRows
        With oWB.Styles(n)
            A(n, 1) = .Name
            A(n, 2) = .BuiltIn
        End With
    Next n
    ListStyles = A
End Function

When using pre-2021 versions of Excel without support for dynamic arrays, consider UseSpillArray.pdf.
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.