Macro - Delete row based on criteria

gomes123

New Member
Joined
Jun 16, 2021
Messages
19
Office Version
  1. 2007
Platform
  1. Windows
I would like a macro to delete all rows, based on the criteria: in column M (starting from cell M2 going down) who's values are less than 1000.

I tried doing something and this is what I got, but it's not working. Help would be appreciated.

VBA Code:
Sub Delete_Rows()
For i = 1 To Selection.Rows.Count
For j = 1 To Selection.Rows.Count
If Selection.Cells(j, 13) <= 1000 Then
Rows(j + 1).EntireRow.Delete
End If
Next j
Next i
End Sub

After that, I would need to delete all rows, with criteria:
in column J (starting from cell J2 going down) who's values are less than 30.
in column C (starting from cell C2 going down) who's values are less than 0.3.

Is there a way to merge all 3 criterias into 1 macro?

Thanks and most appreciated
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi,

It seems to me you would have a smoother way of handling your "delete" objective ... with several criteria, using Filter ....
 
Upvote 1
Solution

Forum statistics

Threads
1,215,364
Messages
6,124,509
Members
449,166
Latest member
hokjock

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