Excel Suppression de lignes avec plusieurs cr
pactoine
-
pactoine -
pactoine -
Bonjour,
Dans un tableau Excel
comment supprimer par macro dans une sélection (ex : de a1 à c20) toutes les lignes ayant les criteres suivants :" #n/a" ;"papa" "maman" sans affecter les autres parties du tableau
D'avance je vous en remercie pour votre aide
Configuration: Windows XP
Firefox 3.0
Dans un tableau Excel
comment supprimer par macro dans une sélection (ex : de a1 à c20) toutes les lignes ayant les criteres suivants :" #n/a" ;"papa" "maman" sans affecter les autres parties du tableau
D'avance je vous en remercie pour votre aide
Configuration: Windows XP
Firefox 3.0
A voir également:
- Excel Suppression de lignes avec plusieurs cr
- Forcer suppression fichier - Guide
- Liste déroulante excel - Guide
- Formule moyenne excel plusieurs colonnes - Guide
- Word et excel gratuit - Guide
- Écrire plusieurs lignes dans une cellule excel mac - Guide
1 réponse
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)
Ca marche super
je t'en remercie beaucoup
pactoine
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
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)
Ca marche super
je t'en remercie beaucoup
pactoine