I need a macro to delete any rows that contains: "duplicate", "inactive", "obsolete", "needs approval", or "removed" in column B.
Any row that contains any of those words should be deleted.
I need a macro to delete any rows that contains: "duplicate", "inactive", "obsolete", "needs approval", or "removed" in column B.
Any row that contains any of those words should be deleted.
Maybe:
[code]
Sub mcrandazz()
Dim rcell As Range
On Error Resume Next
For Each rcell In Range("B2:B" & ActiveSheet.UsedRange.Rows.count)
If rcell.Value Like "*DUPLICATE*" Then rcell.EntireRow.Delete
If rcell.Value Like "*INACTIVE*" Then rcell.EntireRow.Delete
If rcell.Value Like "*OBSOLETE*" Then rcell.EntireRow.Delete
If rcell.Value Like "*NEEDS APPROVAL*" Then rcell.EntireRow.Delete
If rcell.Value Like "*REMOVED*" Then rcell.EntireRow.Delete
Next rcell
On Error GoTo 0
End Sub
[/copy]
My only additional suggestion would be to delete rows from the bottom up as it takes longer if Excel starts to delete from the top. Also I would remove the case-sensitivity:
abousettaPlease Login or Register to view this content.
Last edited by abousetta; 12-11-2013 at 05:15 PM. Reason: minor code adjustment
Please consider:
Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks