Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. 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.
by Allen Wyatt
(last updated July 22, 2017)
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:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12259) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Deleting Unwanted Styles.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
When you paste information from Excel into other programs, you may get more than you actually want. It is not unusual for ...Discover More
Excel allows you to adjust not only the horizontal alignment of values in a cell, but also the vertical alignment. This ...Discover More
Excel allows you to adjust spacing between cell walls and the contents of those cells. It does not, however, allow you to ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.