Filtering data based on two criteria's and then deleting those rows

harvey121

New Member
Joined
Nov 27, 2018
Messages
20
Hi all,

I'm searching for a macro wherein i can filter up to 5000 rows of data based on two conditions and then delete the filtered rows.

An example of what I'm trying to do is as follows:

A sample of my data looks like this:

ColA ColB ColC
[TABLE="width: 342"]
<colgroup><col span="2"><col><col></colgroup><tbody>[TR]
[TD]Date[/TD]
[TD] [/TD]
[TD]Market[/TD]
[TD]Quantity[/TD]
[/TR]
[TR]
[TD="align: right"]31-Jan[/TD]
[TD][/TD]
[TD]sweden[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]25-Nov[/TD]
[TD][/TD]
[TD]us[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD="align: right"]3-Jul[/TD]
[TD][/TD]
[TD]us[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD="align: right"]15-Aug[/TD]
[TD][/TD]
[TD]canada[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD="align: right"]17-Aug[/TD]
[TD][/TD]
[TD]canada[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]17-Nov[/TD]
[TD][/TD]
[TD]canada[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD="align: right"]21-Aug[/TD]
[TD][/TD]
[TD]sweden[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]25-Aug[/TD]
[TD][/TD]
[TD]us[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]28-Aug[/TD]
[TD][/TD]
[TD]us[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD="align: right"]28-Oct[/TD]
[TD][/TD]
[TD]us[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD="align: right"]28-Aug[/TD]
[TD][/TD]
[TD]us[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD="align: right"]26-Feb[/TD]
[TD][/TD]
[TD]sweden[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD="align: right"]31-Aug[/TD]
[TD][/TD]
[TD]sweden[/TD]
[TD="align: right"]4[/TD]
[/TR]
</tbody>[/TABLE]


Now I want to delete all those rows where the Market is Sweden and date is less than 21st March 2018, us and date less than 16th Oct 2018 canada and date less than 23rd Oct 2018.

PS: I'm getting the dates with the following format: 5/31/2018 11:23:51 PM but using short date over here.

Your help guys is really appreciated on this.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Ok then. So your dates are all true dates. Where is the data housed? Which cells? You do have headers right? What is the sheet name? Check there are no trailing spaces after the country names also. Format the dates to number with say 2 decimal places and paste the results. Finally what is the exact code you are running now?
 
Upvote 0
Hi Steve,

I had an extra row in between. Removed it and it worked perfectly.

I have one more query, As I need to shift the Markets column(Col2 over here) to column 6 adding more date in between, so what all change should I make to your previous code.

Ok then. So your dates are all true dates. Where is the data housed? Which cells? You do have headers right? What is the sheet name? Check there are no trailing spaces after the country names also. Format the dates to number with say 2 decimal places and paste the results. Finally what is the exact code you are running now?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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