j'ai tjs un problème avec ma macro, j'ai essayé de l'étendre à plusieurs
cellules mais ca ne marche pa (sauf qd la cellule H19 est égale a 0)
(exemple : H9 <= 16 alors suppression des ligne contenant un Q et un R dans
la colonne A, cette suppresion s'opère dans la première feuille ainsi que
dans les feuilles suivantes dans mon classeur)
Ainsi de suite, H9 <= 14 alors les lignes ayant ds la colonne A, un O ou un
P, sont supprimées dans toute les feuilles du classeur
Si qqun pouvait jeter un coup d'oeil pr m'éclairer!!! (s'il y a possibilité
notamment de la raccourcir...peut etre est ce du à la répétition des
formules???)
If Range("h19") <= "16" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil R" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "16" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil Q" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "14" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil P" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "14" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil O" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "12" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil N" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "12" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil M" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "10" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil L" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "10" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil K" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "8" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil J" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "8" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil I" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "6" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil H" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "6" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil G" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "4" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil F" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "4" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil E" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "2" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil D" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "2" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil C" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") = "0" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil B" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") = "0" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil A" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
Merci beaucoup par avance
Cordialement
PS : excusez-moi pour la longueur ms je préférais vous exposer mon pb en
entier
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
MPi
Salut,
D'après moi, quand tu dois effacer des lignes, il est préférable de commencer par le bas et remonter pour que la boucle se fasse en continu sans problème. Ex: I (la ligne à vérifier) = 10 et la condition est vraie Tu supprimes cette ligne et toutes les autres lignes remontent La ligne 11 devient la 10 La boucle, quand à elle, se refait I = 11, mais la ligne 11 précédente qui est devenue la 10 est omise Il faudrait alors faire I = I - 1
Pour le problème comme tel, je ne connais pas le début de l'histoire... mais tu pourrais grouper tes conditions ensemble et peut-être même utiliser un Select Case pour la lisibilité
La boucle principale (For Ligne = ) n'a pas à être répétée dans chaque condition. En la mettant au début, tu ne passeras qu'une fois dans la liste ce qui devrait être plus rapide.
For ligne = [A65000].End(xlUp).Row to 1 Step -1 Select Case Range("H19") Case 15, 16 If Cells(ligne, 1) = "Fil R" OR Cells(ligne, 1) = "Fil Q" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If
Case 13, 14 If Cells(ligne, 1) = "Fil P" OR Cells(ligne, 1) = "Fil O" Then ... End select Next ligne
En espérant avoir bien compris...
Michel
BONJOUR A TOUTES ET A TOUS!!!!
j'ai tjs un problème avec ma macro, j'ai essayé de l'étendre à plusieurs cellules mais ca ne marche pa (sauf qd la cellule H19 est égale a 0)
(exemple : H9 <= 16 alors suppression des ligne contenant un Q et un R dans la colonne A, cette suppresion s'opère dans la première feuille ainsi que dans les feuilles suivantes dans mon classeur)
Ainsi de suite, H9 <= 14 alors les lignes ayant ds la colonne A, un O ou un P, sont supprimées dans toute les feuilles du classeur
Si qqun pouvait jeter un coup d'oeil pr m'éclairer!!! (s'il y a possibilité notamment de la raccourcir...peut etre est ce du à la répétition des formules???)
If Range("h19") <= "16" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil R" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "16" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil Q" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "14" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil P" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "14" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil O" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "12" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil N" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "12" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil M" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "10" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil L" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "10" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil K" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "8" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil J" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "8" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil I" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "6" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil H" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "6" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil G" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "4" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil F" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "4" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil E" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "2" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil D" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "2" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil C" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") = "0" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil B" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") = "0" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil A" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
Merci beaucoup par avance
Cordialement
PS : excusez-moi pour la longueur ms je préférais vous exposer mon pb en entier
Salut,
D'après moi, quand tu dois effacer des lignes, il est préférable de
commencer par le bas et remonter pour que la boucle se fasse en continu
sans problème.
Ex:
I (la ligne à vérifier) = 10 et la condition est vraie
Tu supprimes cette ligne et toutes les autres lignes remontent
La ligne 11 devient la 10
La boucle, quand à elle, se refait
I = 11, mais la ligne 11 précédente qui est devenue la 10 est omise
Il faudrait alors faire I = I - 1
Pour le problème comme tel, je ne connais pas le début de l'histoire...
mais tu pourrais grouper tes conditions ensemble et peut-être même
utiliser un Select Case pour la lisibilité
La boucle principale (For Ligne = ) n'a pas à être répétée dans chaque
condition. En la mettant au début, tu ne passeras qu'une fois dans la
liste ce qui devrait être plus rapide.
For ligne = [A65000].End(xlUp).Row to 1 Step -1
Select Case Range("H19")
Case 15, 16
If Cells(ligne, 1) = "Fil R" OR Cells(ligne, 1) = "Fil Q" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Case 13, 14
If Cells(ligne, 1) = "Fil P" OR Cells(ligne, 1) = "Fil O" Then
...
End select
Next ligne
En espérant avoir bien compris...
Michel
BONJOUR A TOUTES ET A TOUS!!!!
j'ai tjs un problème avec ma macro, j'ai essayé de l'étendre à plusieurs
cellules mais ca ne marche pa (sauf qd la cellule H19 est égale a 0)
(exemple : H9 <= 16 alors suppression des ligne contenant un Q et un R dans
la colonne A, cette suppresion s'opère dans la première feuille ainsi que
dans les feuilles suivantes dans mon classeur)
Ainsi de suite, H9 <= 14 alors les lignes ayant ds la colonne A, un O ou un
P, sont supprimées dans toute les feuilles du classeur
Si qqun pouvait jeter un coup d'oeil pr m'éclairer!!! (s'il y a possibilité
notamment de la raccourcir...peut etre est ce du à la répétition des
formules???)
If Range("h19") <= "16" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil R" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "16" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil Q" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "14" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil P" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "14" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil O" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "12" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil N" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "12" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil M" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "10" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil L" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "10" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil K" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "8" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil J" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "8" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil I" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "6" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil H" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "6" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil G" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "4" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil F" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "4" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil E" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "2" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil D" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") <= "2" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil C" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") = "0" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil B" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
If Range("h19") = "0" Then
For ligne = 1 To [A65000].End(xlUp).Row
If Cells(ligne, 1) = "Fil A" Then
For Each WS In Worksheets
WS.Rows(ligne).Delete
Next WS
End If
Next
End If
Merci beaucoup par avance
Cordialement
PS : excusez-moi pour la longueur ms je préférais vous exposer mon pb en
entier
D'après moi, quand tu dois effacer des lignes, il est préférable de commencer par le bas et remonter pour que la boucle se fasse en continu sans problème. Ex: I (la ligne à vérifier) = 10 et la condition est vraie Tu supprimes cette ligne et toutes les autres lignes remontent La ligne 11 devient la 10 La boucle, quand à elle, se refait I = 11, mais la ligne 11 précédente qui est devenue la 10 est omise Il faudrait alors faire I = I - 1
Pour le problème comme tel, je ne connais pas le début de l'histoire... mais tu pourrais grouper tes conditions ensemble et peut-être même utiliser un Select Case pour la lisibilité
La boucle principale (For Ligne = ) n'a pas à être répétée dans chaque condition. En la mettant au début, tu ne passeras qu'une fois dans la liste ce qui devrait être plus rapide.
For ligne = [A65000].End(xlUp).Row to 1 Step -1 Select Case Range("H19") Case 15, 16 If Cells(ligne, 1) = "Fil R" OR Cells(ligne, 1) = "Fil Q" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If
Case 13, 14 If Cells(ligne, 1) = "Fil P" OR Cells(ligne, 1) = "Fil O" Then ... End select Next ligne
En espérant avoir bien compris...
Michel
BONJOUR A TOUTES ET A TOUS!!!!
j'ai tjs un problème avec ma macro, j'ai essayé de l'étendre à plusieurs cellules mais ca ne marche pa (sauf qd la cellule H19 est égale a 0)
(exemple : H9 <= 16 alors suppression des ligne contenant un Q et un R dans la colonne A, cette suppresion s'opère dans la première feuille ainsi que dans les feuilles suivantes dans mon classeur)
Ainsi de suite, H9 <= 14 alors les lignes ayant ds la colonne A, un O ou un P, sont supprimées dans toute les feuilles du classeur
Si qqun pouvait jeter un coup d'oeil pr m'éclairer!!! (s'il y a possibilité notamment de la raccourcir...peut etre est ce du à la répétition des formules???)
If Range("h19") <= "16" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil R" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "16" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil Q" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "14" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil P" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "14" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil O" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "12" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil N" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "12" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil M" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "10" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil L" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "10" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil K" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "8" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil J" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "8" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil I" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "6" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil H" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "6" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil G" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "4" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil F" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "4" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil E" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "2" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil D" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") <= "2" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil C" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") = "0" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil B" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
If Range("h19") = "0" Then For ligne = 1 To [A65000].End(xlUp).Row If Cells(ligne, 1) = "Fil A" Then For Each WS In Worksheets WS.Rows(ligne).Delete Next WS End If Next End If
Merci beaucoup par avance
Cordialement
PS : excusez-moi pour la longueur ms je préférais vous exposer mon pb en entier