Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50110

[SOLVED] Delete all non-custom styles

$
0
0
Looking to delete all non-custom styles from a workbook. I cannot find via msdn or other how to point to the parent category. If you expand the Styles on the Ribbon, "Custom" goes at the top, then "Good Bad & Neutral", then "Data & Model", then "Titles & Headings", then "Number Format". I want everything cleared EXCEPT "Custom".

In essence something like:

Code:

Sub DeleteStyles ()

Dim oStyle as Style

For Each oStyle in ThisWorkbook.Styles
  If Not oStyle.ParentCategory = "Custom" Then
      oStyle.Delete
  End If
Next

End Sub

I've bolded the row in question - again, I used plain language within the code to describe my problem.

Thanks

AS

Viewing all articles
Browse latest Browse all 50110

Trending Articles