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

The Power Loon

New Member
Joined
Feb 7, 2020
Messages
34
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

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Do you have a header row in row7?
 
Upvote 0
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
 
Upvote 0
Unfortunately, there is no header in row 7. I'm guessing the script you wrote requires one?
 
Upvote 0
As long as row 7 isn't blank it should work
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

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