VBA macro to remove rows if column has value?

gd6noob

Board Regular
Joined
Oct 20, 2017
Messages
170
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I want to know if theres a marco that can do this and if so, please share.

I want rows that contain any value other then 0 to be deleted.
mso2ROA.jpg


Thanks in advanced.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
How about
Code:
Sub DelNon0()

    With Range("I2:I" & Range("H" & Rows.Count).End(xlUp).Row)
        .Value = Evaluate("if(" & .Offset(, -3).Address & "<>0,1,"""")")
        .SpecialCells(xlConstants).EntireRow.Delete
    End With

End Sub
 
Upvote 0
Thanks... that worked..

another question.
What if the cell is blank instead of having the 0?
Tried to use your macro but so confused..

rRlyu4h.jpg


Thanks in advanced
 
Upvote 0
Try
Code:
Sub DelBlanks()

    Range("S2:S" & Range("A" & Rows.Count).End(xlUp).Row).SpecialCells(xlBlanks).EntireRow.Delete

End Sub
 
Upvote 0
Im getting an error

Run-Time error '1004':
No Cells were found
 
Upvote 0
OK, a couple of questions
1) are the blank cells actually blank, or do they contain formulae returning ""
2) Will column A always have a value in the last row? If not what column will?
 
Upvote 0
Hi Fluffy

Thanks for the quick reply.

As far as I know, the cells are empty..
I'm copying these from another program that I exported to excel.

So basically, I want to delete the rows that have a value under the Vacation column and leave the empty cells.


Thanks
 
Upvote 0
OK, I misunderstood.
Try this, but do it on a copy first as I don't think the blanks are blank
Code:
    With Range("S2:S" & Range("A" & Rows.Count).End(xlUp).Row)
        .Value = .Value
        .SpecialCells(xlConstants).EntireRow.Delete
    End With
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

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