Option Explicit
Sub ClearStyles()
Dim i&, N&, Cell As Range, RangeOfStyles As Range
MsgBox "Depending on how many files & styles you have" & vbLf & _
"this may take some time, so please be patient" & vbLf & _
"" & vbLf & _
"(You will be told when the process is finished)", _
vbInformation, "Information..."
Application.ScreenUpdating = False
Application.EnableEvents = False
With Application.FileSearch
.LookIn = ActiveWorkbook.Path
.Filename = "*.xls"
If .Execute > 0 Then
For N = 1 To .FoundFiles.Count
If .FoundFiles(N) <> ThisWorkbook.FullName Then
Application.Workbooks.Open(.FoundFiles(N)).Activate
Sheets.Add before:=Sheets(1)
For i = 1 To ActiveWorkbook.Styles.Count
[a65536].End(xlUp).Offset(1, 0) = ActiveWorkbook. _
Styles(i).Name
Next
Set RangeOfStyles = Range(Columns(1).Rows(2), _
Columns(1).Rows(65536).End(xlUp))
For Each Cell In RangeOfStyles
If Not Cell.Text Like "Normal" Then
On Error Resume Next
ActiveWorkbook.Styles(Cell.Text).Delete
ActiveWorkbook.Styles(Cell.NumberFormat).Delete
End If
Next Cell
Application.DisplayAlerts = False
ActiveSheet.Delete
ActiveWorkbook.Close savechanges:=True
End If
Next N
End If
End With
MsgBox "Styles cleared from workbooks", vbInformation, "Completed..."
End Sub
|