Deleting rows containg values in a range

DaveUK

Board Regular
Joined
Jan 24, 2005
Messages
245
Please could someone tell me how to do this in VBA.

I have a workbook "DataStorage" which has a worksheet named "Works".
It contains thousands of rows of data starting at row 3.

I am using a workbook "Prep Workbook" which contains a worksheet named "Temp Works".
Starting for cell "C3" i need to select all reference numbers in the column starting at "C3" to an undefined number of rows down.

I need to loop through the range and check on workbook "DataStorage", worksheet named "Works" for the existence, in the same column (starting at column "C3"), of the value in the "Prep Workbook", worksheet named "Temp Works".

If there is a match i need to delete the entire row containing the same value on workbook "DataStorage", worksheet named "Works".

Eg.

Workbook "Prep Workbook", Worksheet "Temp Works"

C

1 02345678
2 78635480
3 93624454
4 03740375

Workbook "Data Storage", Worksheet "Works"

Before running needed macro:

C

1 02345678
2 74935243
3 86753428
3 78635480
4 93624454
5 99028725
6 01017263
7 03740375

After running needed macro:

C

1 74935243
2 86753428
3 99028725
4 01017263

All values are text NOT numbers. The data here is an example and the data will never be the same value.

Thanks in advance.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Add in a vlookup formula to determine which rows you want, then do an autofilter.

Press F5, choose "special" and "visible rows", then delete them.

You can record this as a macro.
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
Members
453,021
Latest member
Justyna P

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