Written by Allen Wyatt (last updated January 21, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365
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:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12259) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Deleting Unwanted Styles.
Program Successfully in Excel! This guide will provide you with all the information you need to automate any task in Excel and save time and effort. Learn how to extend Excel's functionality with VBA to create solutions not possible with the standard features. Includes latest information for Excel 2024 and Microsoft 365. Check out Mastering Excel VBA Programming today!
Want a quick way to add some underlines to your cell values? It's easy using the shortcuts provided in this tip.
Discover MoreConvert a numeric value to text and you may be surprised by how Excel displays the value. Here's a run-down on exactly ...
Discover MoreIf you get an error when you try to use one of your custom views, it could be due to the protection you have applied to ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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
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