ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   if a cell equal to zero how can it delete entire row (https://www.excelbanter.com/excel-programming/391464-if-cell-equal-zero-how-can-delete-entire-row.html)

yehia

if a cell equal to zero how can it delete entire row
 
if a cell equal to zero how can we formulate it to delete the entire row

Gary''s Student

if a cell equal to zero how can it delete entire row
 
For only a single cell, say cell Z100:


Sub demo()
If Range("Z100").Value = 0 Then
Range("Z100").EntireRow.Delete
End If
End Sub


For a range of cells, say all the cells in column Z

Sub demoi()
n = Cells(Rows.Count, "Z").End(xlUp).Row
For i = n To 1 Step -1
If Cells(i, "Z").Value = 0 Then
Cells(i, "Z").EntireRow.Delete
End If
Next
End Sub

--
Gary''s Student - gsnu200730


"yehia" wrote:

if a cell equal to zero how can we formulate it to delete the entire row



All times are GMT +1. The time now is 10:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com