ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro that deletes rows with "0" value cells (https://www.excelbanter.com/excel-programming/383101-macro-deletes-rows-0-value-cells.html)

steven

Macro that deletes rows with "0" value cells
 
Hi,

I have several worksheets with data. I'd like to specify a column and
wherever there is a 0 value in that column, the macro will delete the whole
row it is in. The column to look for the 0 in is different in each of my
worksheets so somehow i have to specify which one it is to the macro
beforhand.

any help aprecciated,

Steven.

PY & Associates

Macro that deletes rows with "0" value cells
 
Try this

Sub m()
colabel = InputBox("column label ?")
lrow = Cells(Rows.Count, colabel).End(xlUp).Row
For i = lrow To 1 Step -1
If Cells(i, colabel) = 0 Then Rows(i).Delete
Next i
End Sub

--
Regards

"steven" wrote in message
...
Hi,

I have several worksheets with data. I'd like to specify a column and
wherever there is a 0 value in that column, the macro will delete the

whole
row it is in. The column to look for the 0 in is different in each of my
worksheets so somehow i have to specify which one it is to the macro
beforhand.

any help aprecciated,

Steven.





All times are GMT +1. The time now is 02:27 AM.

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