Vous utilisez un navigateur obsolète. Il se peut que ce site ou d'autres sites Web ne s'affichent pas correctement. Vous devez le mettre à jour ou utiliser un navigateur alternatif.
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 !
Bonjour
j'ai besoin d'aide
J'ai un classeur comprend deux feuils
Feuil1 comprend trois colonnes A,B,C
Feuil2 : la colonne A et ligne B
L'intersection de colonne A et ligne B donne la valeur C
Merci
Il ne faut pas supprimer les lignes mais les masquer.
Voyez le fichier joint et la macro du bouton :
VB:
Private Sub CommandButton1_Click() 'Masquer ou Afficher
Dim test As Boolean, r As Range
test = CommandButton1.Caption = "Masquer"
Application.ScreenUpdating = False
For Each r In [B2:G15,B19:G32].Rows 'plages à adapter
r.Hidden = test And Application.Sum(r) = 0
Next
CommandButton1.Caption = IIf(test, "Afficher", "Masquer")
End Sub
Il ne faut pas supprimer les lignes mais les masquer.
Voyez le fichier joint et la macro du bouton :
VB:
Private Sub CommandButton1_Click() 'Masquer ou Afficher
Dim test As Boolean, r As Range
test = CommandButton1.Caption = "Masquer"
Application.ScreenUpdating = False
For Each r In [B2:G15,B19:G32].Rows 'plages à adapter
r.Hidden = test And Application.Sum(r) = 0
Next
CommandButton1.Caption = IIf(test, "Afficher", "Masquer")
End Sub
Merci
EN peut masquer les colonnes vides ?
j'ai triuver ce code
Option Compare Text
Sub Masquer()
Dim Scope()
Scope = Array("stock initial", "entrees", "sorties", "stock", "mini", "état de stock")
nrows = ActiveSheet.UsedRange.Rows.Count
For Each Column In Columns
If IsInArray(Column.Cells(1), Scope) Then
If WorksheetFunction.CountA(Column.Cells(3).Resize(nrows - 2)) = 0 Then Column.Hidden = True
End If
Next
End Sub
Function IsInArray(Objet As String, Crit())
IsInArray = True
For Each Elem In Crit
If Trim(Objet) = Elem Then Exit Function
Next
IsInArray = False
End Function
Sub Afficher_tout()
Sheets("stock").Columns.Hidden = False
End Sub
Cela ne paraît pas très judicieux car il peut y avoir des choses à ne pas masquer sous les colonnes.
Mais bon on peut toujours utiliser :
VB:
Private Sub CommandButton1_Click() 'Masquer ou Afficher
Dim test As Boolean, r As Range
test = CommandButton1.Caption = "Masquer"
Application.ScreenUpdating = False
For Each r In [B2:G15,B19:G32].Rows 'plages à adapter
r.Hidden = test And Application.Sum(r) = 0
Next
For Each r In [B2:G15,B19:G32].Columns
r.Hidden = test And Application.Sum(r) = 0
Next
CommandButton1.Caption = IIf(test, "Afficher", "Masquer")
End Sub
Cela ne paraît pas très judicieux car il peut y avoir des choses à ne pas masquer sous les colonnes.
Mais bon on peut toujours utiliser :
VB:
Private Sub CommandButton1_Click() 'Masquer ou Afficher
Dim test As Boolean, r As Range
test = CommandButton1.Caption = "Masquer"
Application.ScreenUpdating = False
For Each r In [B2:G15,B19:G32].Rows 'plages à adapter
r.Hidden = test And Application.Sum(r) = 0
Next
For Each r In [B2:G15,B19:G32].Columns
r.Hidden = test And Application.Sum(r) = 0
Next
CommandButton1.Caption = IIf(test, "Afficher", "Masquer")
End Sub
- 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