title: Having trouble deleting custom styles in Excel 2016
body: <p>I use a large workbook in Excel 2016 and it appears that a large number of custom styles have been imported into the workbook and are messing with the formatting of cells in the workbook. I've tried using the following code to delete the custom styles</p>
  
  <pre><code>Sub clear_all_styles()
  
  Dim styT As Style
  
  For Each styT In ActiveWorkbook.Styles
      If styT.BuiltIn = False Then
          styT.Locked = False
          styT.Delete
      End If
  Next styT
  
  End Sub
  </code></pre>
  
  <p>but the styles are still listed in the Styles ribbon when I execute the code. In addition, when I try to manually delete the styles by right-clicking on them, they don't get deleted.</p>
  
  <p>Any ideas what I'm doing wrong?</p>