XL 2016 Masquer lignes (avec Grouper/Dissocier)

midovic

XLDnaute Nouveau
Bonjour,

Je souhaite une solution pour mon fichier ci-joint. Je vous en remercie par avance!

En fait, e souhaite masquer les lignes dont la somme de la ligne est égale à 0.
J'ai réussi à trouver une macro dans le forum (masquer/afficher) qui fonctionne.
Mon problème est le suivant :
1-Les lignes ont une structure plan (Grouper/Dissocier)
2-Quand j'utilise la macro pour masquer les lignes ca fonctionne, par contre, quand j'utilise tout de suite après les boutons du plan (+ / - / 1 / 2 / ... ) les lignes masquées réapparaissent!
Y a-t-il un moyen pour garder ces lignes masquées même si j'utilise les boutons plan (grouper / dissocier)?

Encore merci par avance.
 

Pièces jointes

  • Masquer_Lignes_avec_Grouper_Dissocier.xlsm
    199.4 KB · Affichages: 5

job75

XLDnaute Barbatruc
Bonjour midovic et bienvenue,

Le bouton soit s'adapter à l'organisation du plan donc utiliser :
VB:
Private Sub CommandButton1_Click()
ActiveSheet.Outline.ShowLevels RowLevels:=IIf(CommandButton1.Caption = "Masquer", 1, 3)
CommandButton1.Caption = IIf(CommandButton1.Caption = "Masquer", "Afficher", "Masquer")
End Sub
A+
 

Pièces jointes

  • Masquer_Lignes_avec_Grouper_Dissocier.xlsm
    189.5 KB · Affichages: 5

midovic

XLDnaute Nouveau
Bonjour midovic et bienvenue,

Le bouton soit s'adapter à l'organisation du plan donc utiliser :
VB:
Private Sub CommandButton1_Click()
ActiveSheet.Outline.ShowLevels RowLevels:=IIf(CommandButton1.Caption = "Masquer", 1, 3)
CommandButton1.Caption = IIf(CommandButton1.Caption = "Masquer", "Afficher", "Masquer")
End Sub
A+
merci beaucoup Job75!
En effet, cette macro permet aussi de masquer les lignes!

Par contre, je pense que j'ai mal formulé ma demande initiale... :)
En fait, quand j'utilise la macro, les lignes sont bien masquées (lignes avec somme 0). Jusqu'à là tout va bien.
Mon problème : quand je veux voir le détail d'une ligne groupée en particulier, quand je déplie le bouton + les lignes 0 réapparaissent ! donc, comment je peux faire pour que c'est lignes à 0 restent masquer?
 

job75

XLDnaute Barbatruc
Si le plan vous gêne eh bien ne l'utilisez pas.
Voyez le fichier joint et cette macro :
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target(1) <> "Afficher" Then Exit Sub
Cancel = True
While Target(2, 1).Text = "0"
    Target(2, 1).EntireRow.Hidden = Not Target(2, 1).EntireRow.Hidden
    Set Target = Target(2, 1)
Wend
End Sub
Cliquez sur le bouton "Masquer" puis double-clic sur "Afficher" en colonne B.
 

Pièces jointes

  • Masquer_Lignes_avec_Grouper_Dissocier.xlsm
    191 KB · Affichages: 7

midovic

XLDnaute Nouveau
Voyez le fichier joint et cette macro :
VB:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target(1) <> "Afficher" Then Exit Sub
Cancel = True
While Target(2, 1).Text = "0"
    Target(2, 1).EntireRow.Hidden = Not Target(2, 1).EntireRow.Hidden
    Set Target = Target(2, 1)
Wend
End Sub
Cliquez sur le bouton "Masquer" puis double-clic sur "Afficher" en colonne B.
C'est très bien comme solution :)
Merci beaucoup job75!
 

Discussions similaires

Statistiques des forums

Discussions
312 207
Messages
2 086 237
Membres
103 162
dernier inscrit
fcfg