VBA or formula to mark or delete rows if not in range

thomassharp

Board Regular
Joined
Dec 10, 2014
Messages
84
Hello,
On Excel 2010.
Not sure if VBA is necessary here: I have two work sheets. Sheet1 with 10000 rows and the Sheet2 with 500 or so. All of Sheet2's data is in Sheet1. Sheet2 is just one column with values in column A; if those values are not in a specified column on Sheet1, i.e. any extra values, what would be the best way to delete the rows or just mark mark them in a helper column for deletion? I can't highlight duplicates then work backwards to get unique values as there are hundreds of duplicates in the sheet already. Everything I have read so far is for the reverse i.e. deleting rows if values are contained in a range.

Thank you



 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hello,
On Excel 2010.
Not sure if VBA is necessary here: I have two work sheets. Sheet1 with 10000 rows and the Sheet2 with 500 or so. All of Sheet2's data is in Sheet1. Sheet2 is just one column with values in column A; if those values are not in a specified column on Sheet1, i.e. any extra values, what would be the best way to delete the rows or just mark mark them in a helper column for deletion? I can't highlight duplicates then work backwards to get unique values as there are hundreds of duplicates in the sheet already. Everything I have read so far is for the reverse i.e. deleting rows if values are contained in a range.

Thank you



Assuming data in sheet1 are in A2:A10001 and data in Sheet2 are in A2:A501, in sheet2 cell B2 place this formula and copy down:
=IF(ISNA(MATCH(A2,Sheet1!$A$2:$A$10001,0)),0,1)

Now sort sheet2 columns A:B by col B, ascending and delete all the rows, if any, with a 0 in col B.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

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