Thread: Deleting styles
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Héctor Miguel Héctor Miguel is offline
external usenet poster
 
Posts: 434
Default Deleting styles

hi, !

When I add from another Excel (2003) file into one of mine, I unfortunately also inherit all of their styles.
I have a file currently with about 50 styles from other people of which about ten of those are different "Normal" styles alone.
I know how to delete them one-by-one via Format, Style, Delete (what a tedious process, MS!) till only those remain that I prefer.
Is here a way that I can select at once all those I don't want and delete in a single stroke?
If not, can someone explain why MS did not allow for this?


the following macros does this:

first: puts all the styles names starting on active cell downward
so you can revise/check/remove/separate/... those you want to remain
and let all-togheter those you want to be deleted/erased/removed/...
select the result contiguous range and run ...

the second: deletes the names in the selected contiguous range (one column)

hth,
hector.

Sub GetStylesNames()
Dim n As Integer
With ActiveWorkbook.Styles
For n = 1 To .Count
ActiveCell.Offset(n - 1) = .Item(n).Name
Next
End With
End Sub

Sub DeleteSelectedStyles()
Dim n As Byte, Styles2Erase As String
For n = 1 To Selection.Count
Styles2Erase = Styles2Erase & Selection.Cells(n) & ""","""
Next
ExecuteExcel4Macro "if(delete.style({""" & Styles2Erase & """}))"
End Sub