Filter words and delete rows (column header..

Closed
Lilly - 24 Nov 2010 à 12:36
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 25 Nov 2010 à 09:47
Hello,


I need to filter out contents containing the word "stock" in column K(and the column header is "Status"), and then delete all rows filtered out. What would be the VBA code for this process? Thank you.

Related:

1 response

TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
25 Nov 2010 à 09:47
Hi Lilly,

Try this code:

Sub test()
Set MR = Range("K2:K100")
    For Each cell In MR
If cell.Value = "stock" Then cell.EntireRow.Delete
    Next
End Sub

There are other structures for doing this, but I really like this one.
You can record a macro, apply filter, show only rows containing "stock" and then delete those rows, stop recording and take a look at the code excel created for you.

Best regards,
Trowa