how to change the macro - delete many rows

Paradi

New Member
Joined
Jul 6, 2018
Messages
7
Hi,

I am asking for help how to change the macro:

Sub Bolts()
With ActiveSheet
.AutoFilterMode = False
With Range("a8", Range("a" & Rows.Count).End(xlUp))
.AutoFilter 1, "*Bolts*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub

This macro finds and removes the specific rows with the word "Bolts"
Can you show me how to change this macro so that macro can also delete rows with many words (such as: cable, radio).

To macro delete rows with words like: "Bolts", "Cable", "radio"

Sorry for my English,. I'm still learning.
Thank You
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How about
Code:
Sub Bolts()
   Dim Ary As Variant
   Dim i As Long
   
   Ary = Array("*bolts*", "*cable*", "*radio*")
   With ActiveSheet
      .AutoFilterMode = False
      With .Range("a8", .Range("a" & Rows.Count).End(xlUp))
         For i = 0 To UBound(Ary)
            .AutoFilter 1, Ary(i)
            On Error Resume Next
            .Offset(1).SpecialCells(12).EntireRow.Delete
            On Error GoTo 0
         Next i
      End With
      .AutoFilterMode = False
   End With
End Sub
This assumes that you cells contain those words.
If they are the only words in the cell, we can get rid of the loop
 
Last edited:
Upvote 0
How about
Code:
    ActiveSheet.Range("$A$1:$Y$15000").AutoFilter Field:=1, Criteria1:=Array( _
    "Bolts", "radio" "Vable"), Operator:=  xlFilterValues
    Range("A1:I15000").SpecialCells(xlCellTypeVisible).EntireRow.Delete  'This delets the range
    ActiveSheet.ShowAllData
 
Upvote 0
Not sure who your talking to, but glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top