Sub test5ok()
[COLOR="Green"]'déclarations[/COLOR]
Dim s As Worksheet, ck$, z$
Dim NL&, NC&, I&, j&, k&, L&
[COLOR="Green"]'figer écran + mode calcul manuel[/COLOR]
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
[COLOR="Green"]'début effacement[/COLOR]
For Each s In Worksheets[COLOR="Green"]'Pour tous les feuilles du classeur[/COLOR]
NL = s.UsedRange.SpecialCells(xlLastCell).Row
[COLOR="Green"]'On détermine le nombre de lignes utilisées :NL[/COLOR]
NC = s.UsedRange.SpecialCells(xlLastCell).Column
[COLOR="Green"]' le nombre de colonnes utilisées : NC[/COLOR]
ck = Left(s.Name, 2)
[COLOR="Green"]' on prend les deux caractères de gauche du nom des feuilles[/COLOR]
z = Chr(61)[COLOR="Green"] ' le caractère ASCII 61 correspond au signe égal[/COLOR]
Select Case ck[COLOR="Green"] 'si ck[/COLOR]
Case "D_" [COLOR="Green"]' est égal à D_[/COLOR]
For I = 4 To NL[COLOR="Green"] 'alors on regarde de la ligne 4 à NL[/COLOR]
For j = 1 To NC'[COLOR="Green"] et de la colonne 1 à NC[/COLOR]
[COLOR="Green"]' si le premier caractère de chaque cellule est différent de z (z valant = )[/COLOR]
If Left(s.Cells(I, j).Formula, 1) <> z Then
s.Cells(I, j).ClearContents[COLOR="Green"]' on efface le contenu de la cellule[/COLOR]
End If
Next j
Next I
Case "V_" [COLOR="Green"]'ici on fait de même pour les feuilles V_[/COLOR]
For k = 6 To NL '[COLOR="Green"]sauf qu'on commence à la ligne 6[/COLOR]
For L = 1 To NC
If Left(s.Cells(k, L).Formula, 1) <> z Then
s.Cells(k, L).ClearContents
End If
Next L
Next k
End Select
Next
[COLOR="Green"]'fin effacement[/COLOR]
[COLOR="Green"]'défiger écran + mode calcul automtique[/COLOR]
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub