Delete Rows If Cell Equals...

svendiamond

Well-known Member
Joined
Jun 13, 2014
Messages
1,504
Office Version
  1. 365
Platform
  1. Windows
I apologize in advance because I know this question has been asked here before. I've been Googling and looking through various posts of people with a similar problem and I still can't seem to get my code to work. I am just trying to delete all rows that have a certain value in column "D"

Let's say the value is the exact text "NONE" I would like to delete the row.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try,

Code:
Sub Delete_Data()
Dim Lrow As Long
Dim i As Long
Lrow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For i = Lrow To 2 Step -1
    If UCase(Cells(i, 4)) = "NONE" Then Rows(i).Delete
Next i
End Sub
 
Upvote 0
I apologize in advance because I know this question has been asked here before. I've been Googling and looking through various posts of people with a similar problem and I still can't seem to get my code to work. I am just trying to delete all rows that have a certain value in column "D"

Let's say the value is the exact text "NONE" I would like to delete the row.
Give this code at try..
Code:
Sub DeleteNONE()
  Columns("D").Replace "NONE", "#N/A", xlWhole
  Columns("D").SpecialCells(xlConstants, xlErrors).EntireRow.Delete
End Sub
 
Upvote 0
Thank you both for your quick responses!

Rick, yours worked perfectly!
 
Upvote 0

Forum statistics

Threads
1,216,117
Messages
6,128,935
Members
449,480
Latest member
yesitisasport

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