Pour supprimer des lignes, il faut partir du bas vers le haut.
Code:
Sub t()
Dim z As Long
'Partir du bas du tableau
For z = Range("G" & Rows.Count).End(xlUp).Row To 2 Step -1
If Range("G" & z) = "X1" Then Range("G" & z).EntireRow.Delete xlShiftUp
Next z
End Sub
Bonjour
tu pourras t'inspirer de ce code
Sub DeleteRows
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim Findstring as string, RngB as range, Lr&
lr = Cells(Rows.Count, "A").End(xlUp).Row
FindString = "X1"
Set Rngb = Range("X:X" & lastrow).Find(what:=FindString, lookat:=xlWhole)
While Not (rngb Is Nothing)
rngb.entirerow.Delete
Set rngb = Range("A:A" & lastrow).Find(what:=FindString, lookat:=xlWhole)
Wend
set rngB=nothing
Application.Calculation = xlCalculationAutomatic
End Sub
si l'on veut utiliser la méthode "find", autant la combiner avec la méthode "FindNext" étudiée pour, enfin me semble t-il :
Code:
Dim c As Range
With Sheets("feuil1").Columns(7)
Set c = .Find("X1", , xlValues, xlWhole, , , False)
If Not c Is Nothing Then
Do
c.EntireRow.Delete
Set c = .FindNext
Loop While Not c Is Nothing
End If
End With