VBA Find and Delete Row question?

stvnhdmpa

New Member
Joined
May 7, 2011
Messages
11
I'm a newb to VBA and I am trying to find and delete all items in a sheet that equal zero.

For example: my sheet "FINAL_INVENTORY" has a column "K" with the number of items on hand. I want to search through the Range "K:K" and find any cell that has a value of 0 and delete the entire row. Once it reaches the end of cells with values, I want it to stop.

Any help would be greatly appreciated.

Regards!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Code:
Sub delrowswith0()
Dim x
On Error Resume Next
With Range("K:K")
    x = .Replace("0", "", xlWhole)
    .SpecialCells(4).EntireRow.Delete
End With
End Sub
 
Upvote 0
Thanks. I was able to get this working. Marcelo, that is a great reference. I have saved it to my favorites.
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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