Remove data from one list based on another list

mattd4385

New Member
Joined
Nov 15, 2010
Messages
42
I have a list a data on sheet1 col_A,
And a list of data in sheet2 col_A.

The List in sheet1 contains all the data i would like to remove from sheet2 (i would like to remove the row not just the cell).

Other notes:
The sheets can not be sorted in any way.
Sheet1 the removel list dosn't contain repeats
sheet2 may contain repeats


-----Ex.-------
sheet1 col_A: (nothing will change on this sheet it is only a list)
1
4
3
2

sheet2 col_A: (BEFORE)
3
1
12
2
16
4
36

sheet2 col_A: (AFTER)
12
16
36
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try:
Code:
Sub FilterAndDelete()
    
Dim c As Range

On Error Resume Next
Application.ScreenUpdating = False

'Change sheet names to match your workbook

With Sheet1
For Each c In .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
    
    With Sheet2
        .Range("A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=c.Value
        .Range("A1").Offset(1, 0).Resize(.Rows.Count - 1, 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete Shift:=xlUp
    End With
    
Next c

End With

Sheet2.AutoFilterMode = False

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,815
Members
452,946
Latest member
JoseDavid

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