Macro To Look At Specific Data In Cells And Delete Entire Rows

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,786
Office Version
  1. 365
Platform
  1. Windows
I need a macro for something I do every day and I cant record it as it has different amounts everyday. I need the macro to look at column 'B' and any cell where the second digit is an R I need the entire row deleted. I then need it sorted smallest to largest by column 'D' (row 1 has headers).

Column D will then have values starting with a minus number gradually rising to positive numbers, I then need anything with a zero or higher those rows totally deleted, keeping the rows with a minus value in column 'D'.

The format of the data in column 'B' is normally 2 letters then 6 numbers i.e MR123456, JD456789, XX123456 etc...

Is this possible?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi. ASAP is brilliant but it won't help you with this sort of issue.

Your code is fine but you could replace

Code:
If Range("C" & i).Value = "NPPACK" Then Rows(i).Delete
If Range("C" & i).Value = "EXPOSTER" Then Rows(i).Delete
If Range("C" & i).Value = "GYREGISTER" Then Rows(i).Delete
If Range("C" & i).Value = "INFOSHEET" Then Rows(i).Delete

with

Code:
With Range("C" & i)
    If .Value = "NPPACK" Or .Value = "EXPOSTER" Or .Value = "GYREGISTER" Or .Value = "INFOSHEET" Then Rows(i).Delete
End With

or (just showing off :))

Code:
If IsNumeric(Application.Match(Range("C" & i).Value, Array("NPPACK", "EXPOSTER", "GYREGISTER", "INFOSHEET"), 0)) Then Rows(i).Delete

No criticism intended at all. You will become good at this with time and studying the posts on this fine forum.
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,544
Members
452,925
Latest member
duyvmex

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