Bonsoir,
A tout hasard, tu colles cette procédure dans un module (Alt + F11, clic droit, Insertion Module)
Quand tu es dans le VBE, tu fais Outils/Références, et tu rajoutes la référence :
Microsoft Forms 2.0 Object Library
et ensuite, tu déroules les deux procédures du haut
Procédure de Laurent Longre....
Sub SupprFormatsInutilisés()
SupprFormats True
End Sub
Sub SupprFormatsCellulesVides()
SupprFormats False
End Sub
Private Sub SupprFormats(Min As Boolean)
Dim Form As String, Prev As String, F As String
Dim I As Integer, J As Integer
Dim dObj As New DataObject, C As New Collection
Dim Wksht As Worksheet, Cell As Range, Shts As Sheets
Application.ScreenUpdating = False
Application.EnableCancelKey = xlDisabled
Application.StatusBar = "Collecte des formats en cours..."
Do
J = (J + 1) Mod 5
If J = 0 Then I = I + 1
Application.SendKeys "{TAB}{END}{TAB 2}{HOME}" & IIf(I, "{PGDN " _
& I & "}", "") & IIf(J, "{DOWN " & J & "}", "") & "+{TAB}^c{ESC}"
Application.Dialogs(xlDialogFormatNumber).Show
dObj.GetFromClipboard
Form = dObj.GetText(1)
If Form = Prev Then Exit Do
C.Add Form, Form
Prev = Form
Loop
Application.StatusBar = "Recherche des formats utilisés en cours..."
Set Shts = ActiveWindow.SelectedSheets
On Error Resume Next
For Each Wksht In Worksheets
Wksht.Select
For Each Cell In Wksht.UsedRange
If Not IsEmpty(Cell) Or Min Then
F = C.Item(Cell.NumberFormatLocal)
If F <> "" Then
C.Remove Cell.NumberFormatLocal
F = ""
End If
End If
Next Cell
Next Wksht
Application.ScreenUpdating = False
Err.Clear
Application.StatusBar = False
J = 0
With ActiveWorkbook
Workbooks.Add
For I = 1 To C.Count
Range("A1").NumberFormatLocal = C(I)
.DeleteNumberFormat ActiveCell.NumberFormat
If Err = 0 Then J = J + 1 Else Err.Clear
Next I
MsgBox J & " format(s) inutilisé(s) supprimé(s).", vbInformation
End With
ActiveWorkbook.Close False
Shts.Select
End Sub