VBA - Search workbook for list in sheet1, and delete all rows containing those values

The Power Loon

New Member
Joined
Feb 7, 2020
Messages
29
Office Version
  1. 365
Platform
  1. Windows
I found similar requests here, but nothing that I could make work for what I needed.

I have a list of over 200 inactive part numbers (and more may need to be added) in Sheet1 column A. In all other sheets in the workbook I want to search through column C, starting at row 8, and delete the row if column C contains a inactive part number from the Sheet1 list.

I apologize for not including a draft of the non-functional script I have, but I'd prefer to avoid tainting your consideration of the best method by which to complete this.

I appreciate your time and consideration of this request,
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,510
Office Version
  1. 365
Platform
  1. Windows
Do you have a header row in row7?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,510
Office Version
  1. 365
Platform
  1. Windows
Assuming the answer to post#2 is yes, try
VBA Code:
Sub ThePowerLoon()
   Dim Ws As Worksheet, S1 As Worksheet
   Dim Cl As Range
   
   Set S1 = Sheets("Sheet1")
   With CreateObject("scripting.dictionary")
      For Each Cl In S1.Range("A2", S1.Range("A" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = Empty
      Next Cl
      For Each Ws In Worksheets
         If Not Ws.Name = S1.Name Then
            Ws.Range("A7:C7").AutoFilter 3, .Keys, xlFilterValues
            Ws.AutoFilter.Range.Offset(1).EntireRow.Delete
            Ws.AutoFilterMode = False
         End If
      Next Ws
   End With
End Sub
 

The Power Loon

New Member
Joined
Feb 7, 2020
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Unfortunately, there is no header in row 7. I'm guessing the script you wrote requires one?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,510
Office Version
  1. 365
Platform
  1. Windows
As long as row 7 isn't blank it should work
 

The Power Loon

New Member
Joined
Feb 7, 2020
Messages
29
Office Version
  1. 365
Platform
  1. Windows
It works perfectly.

Thank you for your work on this, I greatly appreciate it.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,510
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,175,533
Messages
5,897,961
Members
434,688
Latest member
vi28

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
Top