A voir également:
- Excel Suppression de lignes avec plusieurs cr
- Liste déroulante excel - Guide
- Formule excel - Guide
- Aller à la ligne excel - Guide
- Forcer suppression fichier - Guide
- Suppression compte instagram - Guide
1 réponse
Mike-31
Messages postés
18188
Date d'inscription
dimanche 17 février 2008
Statut
Contributeur
Dernière intervention
13 mars 2023
5 041
19 juin 2009 à 21:33
19 juin 2009 à 21:33
Salut,
Testes ce code s'il te convient, on verra plus tard pour l'alléger. Attention avec "#N/A", c'est un message d'erreur Excel pour l'intégrer dans le code , comme tu l'a mis dans ton post :" #n/a" avec un intervalle devant il est considéré comme texte ça marche sinon le code plantera ou remplaces ce critère par autre chose
Sub Macro3()
Dim Lig As Long
Dim LigFinA As Long
Dim Col As Integer
Dim NbrLig As Long
Const PremLig = 2 'Première ligne à traiter
Col = 1 ' traite la colonne A
LigFinA = Feuil1.Range("A65536").End(xlUp).Row + 1
With Sheets("Feuil1")
NbrLig = .Cells(65536, Col).End(xlUp).Row
For Lig = PremLig To NbrLig
If .Cells(Lig, Col).Value = "papa" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = "maman" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = " #N/A" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
Next
End With
Col = 2 ' traite la colonne B
LigFinA = Feuil1.Range("A65536").End(xlUp).Row + 1
With Sheets("Feuil1")
NbrLig = .Cells(65536, Col).End(xlUp).Row
For Lig = PremLig To NbrLig
If .Cells(Lig, Col).Value = "papa" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = "maman" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = " #N/A" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
Next
End With
End Sub
A+
Mike-31
Un problème sans solution est un problème mal posé (Einstein)
Testes ce code s'il te convient, on verra plus tard pour l'alléger. Attention avec "#N/A", c'est un message d'erreur Excel pour l'intégrer dans le code , comme tu l'a mis dans ton post :" #n/a" avec un intervalle devant il est considéré comme texte ça marche sinon le code plantera ou remplaces ce critère par autre chose
Sub Macro3()
Dim Lig As Long
Dim LigFinA As Long
Dim Col As Integer
Dim NbrLig As Long
Const PremLig = 2 'Première ligne à traiter
Col = 1 ' traite la colonne A
LigFinA = Feuil1.Range("A65536").End(xlUp).Row + 1
With Sheets("Feuil1")
NbrLig = .Cells(65536, Col).End(xlUp).Row
For Lig = PremLig To NbrLig
If .Cells(Lig, Col).Value = "papa" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = "maman" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = " #N/A" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
Next
End With
Col = 2 ' traite la colonne B
LigFinA = Feuil1.Range("A65536").End(xlUp).Row + 1
With Sheets("Feuil1")
NbrLig = .Cells(65536, Col).End(xlUp).Row
For Lig = PremLig To NbrLig
If .Cells(Lig, Col).Value = "papa" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = "maman" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
If .Cells(Lig, Col).Value = " #N/A" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
Next
End With
End Sub
A+
Mike-31
Un problème sans solution est un problème mal posé (Einstein)
20 juin 2009 à 00:24
Ca marche super
je t'en remercie beaucoup
pactoine
20 juin 2009 à 00:29
Dans un tableau Excel
comment supprimer par macro dans une sélection (ex : de a1 à a10 et de a15 à a20) toutes les lignes ayant le critere suivants :" "false" sans affecter les autres parties du tableau
merci pour votre aide
21 juin 2009 à 16:05
Tu aurais du ouvrir ta propre discussion pour qu'un maximum d'intervenants prennent connaissance de ton problème et avoir des réponses.
Pour ton problème, les lignes entre les lignes 10 et 15 peuvent elles contenir "false", parce que s'il est impossible qu'elles contiennent cette valeur, la même macro s'applique. Si ça ne correspond pas à tes attentes, donnes plus de précisions
Sub Macro3()
Dim Lig As Long
Dim LigFinA As Long
Dim Col As Integer
Dim NbrLig As Long
Const PremLig = 1 'Première ligne à traiter
Col = 1 ' traite la colonne A
LigFinA = Feuil1.Range("A65536").End(xlUp).Row + 1
With Sheets("Feuil1")
NbrLig = .Cells(65536, Col).End(xlUp).Row
For Lig = PremLig To NbrLig
If .Cells(Lig, Col).Value = "false" Then
.Rows(Lig).Delete
LigFinA = LigFinA + 1
Lig = Lig - 1
End If
End With
End Sub
A+
Mike-31
Un problème sans solution est un problème mal posé (Einstein)
22 juin 2009 à 17:27
Ca marche super
je t'en remercie beaucoup
pactoine