Private Sub Workbook_Open()
Dim O As Worksheet 'déclare la variable O (Onglets)
Dim DL As Long 'déclare la variable DL (Dernière ligne)
Dim I As Long 'déclare la variable I (Incrément)
Application.ScreenUpdating = False 'masque ls rafraîchissements d'écran
For Each O In Sheets 'boucle sur tous les onglets du classeur
DL = O.Cells(Application.Rows.Count, "D").End(xlUp).Row 'définit la dernière ligne éditée DL de la colonne D de l'onglet O
If DL > 1 Then Rows(DL + 1 & ":" & Application.Rows.Count).Hidden = True 'si DL est supérieur à 1, masque toutes les lignes après DL
For I = 1 To DL 'boucle de 1 à DL
'si la cellule ligne I colonne D est différente de "N", masque la ligne I
If UCase(O.Cells(I, "D").Value) <> "N" Then Rows(I).Hidden = True
Next I 'prochaine ligne de la boucle
Next O 'prochain onglet du classeur
Application.ScreenUpdating = True 'affiche ls rafraîchissements d'écran
End Sub
Sub Masquer()
Dim WS As Worksheet, cel As Range, i As Long
For Each WS In ThisWorkbook.Worksheets
WS.Activate
For i = 1 To Rows.Count
If Cells(i, 4) = "n" Then
Cells(i, 4).Rows.Hidden = True
End If
Next
Next
End Sub
Option Explicit
Sub Masquer_si_valeur_x_en_y()
Dim c As Range, o As Object
For Each o In Worksheets
On Error Resume Next
For Each c In o.Columns(4).SpecialCells(xlCellTypeFormulas, 23)
If c.Value = "n" Then c.EntireRow.Hidden = True
Next
On Error GoTo 0
Next
End Sub
Autre suggestion (dans "ThisWorkbook") :...AUTOMATIQUEMENT...
Option Explicit
Private Sub Workbook_SheetSelectionChange(ByVal o As Object, ByVal c As Range)
Application.EnableEvents = False
On Error Resume Next
For Each c In o.Columns(4).SpecialCells(xlCellTypeFormulas, 23)
If c.Value = "n" Then c.EntireRow.Hidden = True
Next
Application.EnableEvents = True
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal R As Range)
On Error Resume Next 'pas de n
For Each R In Sh.[D:D].SpecialCells(xlCellTypeFormulas)
Rows(R.Row).Hidden = R.Value = "n"
Next
End Sub
ÓÒ, peux-tu m’apprendre quel est le rôle du 23 dans .SpecialCells(xlCellTypeFormulas, 23) ?
Merci