XL 2016 Intersection colonnes et lignes

Seddiki_adz

XLDnaute Impliqué
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
 

Pièces jointes

  • Classeur N.xlsm
    10.1 KB · Affichages: 11

job75

XLDnaute Barbatruc
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
 

Pièces jointes

  • Classeur N(1).xlsm
    25.4 KB · Affichages: 5

Seddiki_adz

XLDnaute Impliqué
M
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
 
Dernière édition:

job75

XLDnaute Barbatruc
EN peut masquer les colonnes vides ?
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
 

Pièces jointes

  • Classeur N(2).xlsm
    25.7 KB · Affichages: 6

Seddiki_adz

XLDnaute Impliqué
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
Excellent
Merci bq
 

Discussions similaires

Membres actuellement en ligne

Statistiques des forums

Discussions
312 229
Messages
2 086 426
Membres
103 206
dernier inscrit
diambote