VB 48
Excel Mass delete styles By mike on 28th March 2021 03:55:15 PM
  1. https://excel.tips.net/T002135_Deleting_Unwanted_Styles.html
  3. 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:
  5. 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.
  7. -----------------------------------------------------------
  9. Sub StyleKill()
  10.     Dim styT As Style
  11.     Dim intRet As Integer
  13.     For Each styT In ActiveWorkbook.Styles
  14.         If Not styT.BuiltIn Then
  15.             intRet = MsgBox("Delete style '" & styT.Name & "'?", vbYesNo)
  16.             If intRet = vbYes Then styT.Delete
  17.         End If
  18.     Next styT
  19. End Sub
  21. ===========================================================
  22. Or the same code without confirmation. Just let it run and sit tight....
  24. -----------------------------------------------------------
  26. Sub StyleKill()
  27.     Dim styT As Style
  28.     Dim intRet As Integer
  30.     For Each styT In ActiveWorkbook.Styles
  31.         If Not styT.BuiltIn Then styT.Delete
  32.     Next styT
  33. End Sub

Hasta la pasta! is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.