Forum Discussion
ALASKANBULLWORM
Aug 16, 2021Copper Contributor
VBA delete loop only deletes one line
Hello,
I'm trying to create a macro that deletes all lines in a workbook having specific values, here is my code:
Sub DeleteRowswithSpecificValue()
Dim cell As Range
For Each cell In Range("x2:x2000")
If cell.Value = "defer" Then
cell.EntireRow.Delete
End If
Next cell
End Sub
The macro serves only to delete the first row containing the value not every row. I'll attach the file I want it to work on.
Thanks in advance!
2 Replies
- NikolinoDEPlatinum Contributor
If you don't necessarily want to do it with VBA, an alternative with a filter could also help.
Example in the inserted file.
I would be happy to know if I could help.
Nikolino
I know I don't know anything (Socrates)
* Kindly Mark and Vote any reply if it helps please, as it will be beneficial to more Community members reading here.
- ALASKANBULLWORMCopper ContributorNikolinoDE
Thank you for your reply. I am aware of this option, I am trying to create a large series of these macro functions to transform these data files regularly, more quickly, and for individuals I work with who have less knowledge of excel.