Vous utilisez un navigateur obsolète. Il se peut que ce site ou d'autres sites Web ne s'affichent pas correctement. Vous devez le mettre à jour ou utiliser un navigateur alternatif.
Boostez vos compétences Excel avec notre communauté !
Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force.
Apprenez, échangez, progressez – et tout ça gratuitement !
👉 Inscrivez-vous maintenant !
Sub supprimevideCOLONNEB()
[COLOR="seagreen"]'inspiré par Tirex28[/COLOR]
Application.ScreenUpdating = False
With Range("B1", Range("B65536").End(xlUp))
[COLOR="SeaGreen"]'pour changer de colonne
'remplacer B par la lettre de la colonne choisie[/COLOR]
.AutoFilter field:=1, Criteria1:="=0"
.SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
End Sub
Sub Macro2()
Dim Rng As Range
Dim cell As Range
Set Rng = Range("A20", Range("IV20").End(xlToLeft))' a adapte à ton besoin
For Each cell In Rng
If cell.Value = 0 Then
Range(cell, cell.End(xlUp)).Delete Shift:=xlToLeft
End If
Next cell
End Sub
en fait il faudrait lui dire (à la macro) que quand une cellule du rang 20 est égale à 0 alors les lignes supérieures et cette même ligne 20 sont effacées...
edit: si un puriste du code VBA pouvait , svp, me dire comment
faire une syntaxe moins tarabiscotée
Merci
Code:
Sub Macrotest()
Dim Rng As Range
Dim Rng2 As Range
Dim cell As Range
Dim Ncol As Integer
Set Rng = Range("A20", Range("IV20").End(xlToLeft))
Ncol = Rng.Columns.Count
Set Rng2 = Range("A20").CurrentRegion.Resize(19, Ncol)
For Each cell In Rng
If cell.Value = 0 Then Rng2.Cells.EntireRow.Delete
Next cell
Verif = MsgBox("Voulez-vous vraiment supprimer cette ligne?")
If Verif = vbOK Then [A1].EntireRow.Delete
End Sub
Un début de piste
A tester (pas sur le fichier original) Avec données en A1:A19 (<>0) et A20=0
Code:
[COLOR=silver]Sub Macro2()[/COLOR]
[COLOR=silver]Application.ScreenUpdating = False[/COLOR]
[COLOR=silver]With Range("A1")[/COLOR]
[COLOR=silver] If Not AutoFilterMode Then[/COLOR]
[COLOR=silver] .AutoFilter 1, "<>0", Operator:=xlAnd[/COLOR]
[COLOR=silver] .SpecialCells(xlCellTypeVisible).CurrentRegion.EntireRow.Delete[/COLOR]
[COLOR=silver] End If[/COLOR]
[COLOR=silver]End With[/COLOR]
[COLOR=silver]Rows("1:1").Delete Shift:=xlUp[/COLOR]
[COLOR=silver]End Sub[/COLOR]
- Navigue sans publicité - Accède à Cléa, notre assistante IA experte Excel... et pas que... - Profite de fonctionnalités exclusives Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel. Je deviens Supporter XLD