supression lignes vides conditions supplémentaire

G

gib

Guest
Bonjour à tous

j'utilise une macro pour masquer des lignes lorsqu'une cellule est vide la macro est la suivante

Sheets("60").Select
Dim cell As Range

For Each cell In Range("E1:E1000")
If cell.Value = "0" Then
cell.EntireRow.Hidden = True
End If
Next cell

End Sub

j'aimerai rajouter comme condition de masquer la ligne que si la cellule g est nul (ie: masquer la ligne si et seulement si la cellule E et la cellule G sont vide)

Quelqu'un pourrait-il m'indiquer comment faire?
Merci d'avance
Amicalement.
 
T

tracor

Guest
salut gib

essaye cela

Sub macro()

Sheets("60").Select
Dim cell As Range

For Each cell In Range("E1:g1000")
If cell.Value = "0" And cell.Offset(0, 2).Value = "0" Then
cell.EntireRow.Hidden = True
End If
Next cell

End Sub

tracor
 
O

omicron

Guest
Bonsoir gib,

Tu trouveras en pièce jointe un petit exemple répondant au problème posé

=====================================================
Private Sub CommandButton1_Click()
'Ce bouton affiche toutes les lignes
Set Rng = Range("1:40") '>>> Zone à analyser= Lignes 1 à 40 (Ajustable)
Application.ScreenUpdating = False
For Each Row In Rng.Rows
Row.Hidden = False
Next Row
Application.ScreenUpdating = True
End Sub
=====================================================
Private Sub CommandButton2_Click()
'Ce bouton masque les lignes dont les cellule E et G sont vides
Set Rng = Range("1:40") '>>> Zone à analyser= Lignes 1 à 40 (Ajustable)
Application.ScreenUpdating = False
For Each Row In Rng.Rows
If Row.Columns("E") = "" And Row.Columns("G") = "" Then Row.Hidden = True
Next Row
Application.ScreenUpdating = True
End Sub
=====================================================

En te souhaitant bon courage pour la suite ....

Omicron.
 

Pièces jointes

  • MasquerSi-E-G-Vides.zip
    15 KB · Affichages: 18
O

omicron

Guest
Re-Bonsoir Gib,

Précision supplémentaire :
Si la feuille "60" n'est pas active au moment du lancement de la macro, alors coder :

=====================================================
Private Sub CommandButton1_Click()
'Ce bouton affiche toutes les lignes
Set Rng = Sheets("60").Range("1:40") '>>> Zone à analyser= Lignes 1 à 40 (Ajustable)
Application.ScreenUpdating = False
For Each Row In Rng.Rows
Row.Hidden = False
Next Row
Application.ScreenUpdating = True
End Sub
=====================================================
Private Sub CommandButton2_Click()
'Ce bouton masque les lignes dont les cellule E et G sont vides
Set Rng = Sheets("60").Range("1:40") '>>> Zone à analyser= Lignes 1 à 40 (Ajustable)
Application.ScreenUpdating = False
For Each Row In Rng.Rows
If Row.Columns("E") = "" And Row.Columns("G") = "" Then Row.Hidden = True
Next Row
Application.ScreenUpdating = True
End Sub
=====================================================

Omicron
 

Discussions similaires

Réponses
21
Affichages
284
Réponses
1
Affichages
164
Réponses
0
Affichages
148

Statistiques des forums

Discussions
312 193
Messages
2 086 059
Membres
103 110
dernier inscrit
Privé