VBA to delete rows base on certain numbers in Column D

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,125
Office Version
  1. 365
Platform
  1. Windows
Hi i have alot of delete row codes if cell is empty or even if certain columns have certain names.

What i need help on now is Delete entire row except for these numbers in Column D 74,70,113,13,69,115

Any help thanks
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
How about
Code:
Sub delRws()
With Range("D2", Range("D" & Rows.count).End(xlUp))
   .Value = Evaluate(Replace("if((@=74)+(@=70)+(@=113)+(@=13)+(@=69)+(@=115),@,"""")", "@", .Address))
   .SpecialCells(xlBlanks).EntireRow.Delete
End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Hi im back one more thing i ran into. I need to also do this similar thing. Delete these rows with these numbers in D except for everything else.
 
Upvote 0
So instead of deleting everything except these numbers in D. I want to actually delete these rows with these number except everything else on my sheet. Its like the opposite
 
Upvote 0
In that case try
Code:
Sub delRws()
With Range("D2", Range("D" & Rows.count).End(xlUp))
   .Value = Evaluate(Replace("if((@=74)+(@=70)+(@=113)+(@=13)+(@=69)+(@=115),[COLOR=#ff0000]"""",@[/COLOR])", "@", .Address))
   .SpecialCells(xlBlanks).EntireRow.Delete
End With
End Sub
However any rows that are blank in col D will get deleted.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

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