VBA - Remove rows where a cell in a column is NOT blank

aminero

New Member
Joined
Oct 24, 2019
Messages
4
Hi all,
I am trying to remove rows based on if a cell in column C is not blank for that row. Ive searched multiple threads but nothing is seeming to work for me. I have this one below that works great for removing rows where a cell IS blank. But I need to remove if the cell actually contains info.

Dim d9 As Range
Dim SrchRng9


Set SrchRng9 = ActiveSheet.Range("c2", ActiveSheet.Range("c1000").End(xlUp))
Do
Set d9 = SrchRng9.Find("", LookIn:=xlValues)
If Not d9 Is Nothing Then d9.EntireRow.Delete
Loop While Not d9 Is Nothing
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Can you explain more what you need to do? Use sample data please
 
Upvote 0
Hi, I am unable to attach a file per my permissions? But I have a data set for an open pipeline of orders with about 10 columns. Some of the orders get put on hold for various reasons. I am wanting to remove all orders that are on hold from the data. So I am either trying to keep all rows where the hold column (c) is empty, or I can remove rows where the hold column has an input. Since the inputs vary I was going with the keep rows where column c is blank route but either option would work. Does that make sense?
 
Upvote 0
Please write it out like this. You can add a table on here


[TABLE="width: 500"]
<tbody>[TR]
[TD]Pipeline[/TD]
[TD]Hold or not[/TD]
[/TR]
[TR]
[TD] Data[/TD]
[TD]data[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0
How about this:

Code:
Sub delblanks()


    Dim SrchRng9 As Range
    Dim i As Long


    Set SrchRng9 = ActiveSheet.Range("c2", ActiveSheet.Range("c1000").End(xlUp))
    For i = SrchRng9.Rows.Count To 1 Step -1
        If SrchRng9.Cells(i) <> "" Then SrchRng9.Cells(i).EntireRow.Delete
    Next


End Sub
 
Last edited:
Upvote 0
You're welcome. I was happy to help. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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