XL 2021 Masquer ligne vba

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

NicolasKH

XLDnaute Junior
bonjour tout le monde
je n'arrive pas a cacher une ligne sous condition
j'ai dans la colonne L une formule =SI([@[Date de fin]]>AUJOURDHUI();"En Cour";"Terminer")

je desirerais que quand dans le colonne L est inscrit Terminer que cette meme ligne sois cacher automatiquement

voici mon code

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo err
If Not Intersect(Target, Range("L:L")) Is Nothing Then
If Target = "Terminer" Then
Rows(Target.Row).EntireRow.Hidden = True
MsgBox "Ligne " & Target.Row & " masquée"
End If
End If
Exit Sub
err:

End Sub

mais rien ne se passe

pouviez vous m'aider s'il vous plait car je suis un nul en vba
 

Pièces jointes

Solution
Bonjour @NicolasKH 🙂,

J'ai modifié la formule : =SI([@[Date de fin]]>AUJOURDHUI();"En Cours";"Terminé")
Voir le code suivant:
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xrg As Range, x
   If Range("a5").ListObject.ListRows.Count = 0 Then Exit Sub
   If Intersect(Target, Range("a5").ListObject.ListColumns("Date de fin").DataBodyRange) Is Nothing Then Exit Sub
   Application.ScreenUpdating = False
   Set xrg = Range("a5").ListObject.ListColumns("Etat").DataBodyRange
   For Each x In xrg.Cells: Rows(x.Row).EntireRow.Hidden = (x = "Terminé"): Next x
End Sub




.
merci mapomme pour ta reponse superb rapide et j'ai fais le test et tout fonctionne correctement comme je le desirais, je mets que...
Bonjour @NicolasKH 🙂,

J'ai modifié la formule : =SI([@[Date de fin]]>AUJOURDHUI();"En Cours";"Terminé")
Voir le code suivant:
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xrg As Range, x
   If Range("a5").ListObject.ListRows.Count = 0 Then Exit Sub
   If Intersect(Target, Range("a5").ListObject.ListColumns("Date de fin").DataBodyRange) Is Nothing Then Exit Sub
   Application.ScreenUpdating = False
   Set xrg = Range("a5").ListObject.ListColumns("Etat").DataBodyRange
   For Each x In xrg.Cells: Rows(x.Row).EntireRow.Hidden = (x = "Terminé"): Next x
End Sub




.
 

Pièces jointes

Bonjour @NicolasKH 🙂,

J'ai modifié la formule : =SI([@[Date de fin]]>AUJOURDHUI();"En Cours";"Terminé")
Voir le code suivant:
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xrg As Range, x
   If Range("a5").ListObject.ListRows.Count = 0 Then Exit Sub
   If Intersect(Target, Range("a5").ListObject.ListColumns("Date de fin").DataBodyRange) Is Nothing Then Exit Sub
   Application.ScreenUpdating = False
   Set xrg = Range("a5").ListObject.ListColumns("Etat").DataBodyRange
   For Each x In xrg.Cells: Rows(x.Row).EntireRow.Hidden = (x = "Terminé"): Next x
End Sub




.
merci mapomme pour ta reponse superb rapide et j'ai fais le test et tout fonctionne correctement comme je le desirais, je mets que la reponse est resolu
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
9
Affichages
194
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
479
  • Question Question
Microsoft 365 Probléme VBA
Réponses
8
Affichages
317
Réponses
8
Affichages
233
Retour