ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting entire rows based on certain criteria (https://www.excelbanter.com/excel-programming/303841-deleting-entire-rows-based-certain-criteria.html)

Nan[_4_]

Deleting entire rows based on certain criteria
 
Is there a way to automatically delete any row that has a 0 in both of
specified columns (i.e. BF and BG)?

Thanks for any help

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Deleting entire rows based on certain criteria
 
Hi
try the following macro:
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Application.ScreenUpdating = False
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
If Cells(row_index, "BF").Value= 0 and _
Cells(row_index, "BG").Value= 0 then
Rows(row_index).delete
End If
Next
Application.ScreenUpdating = True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Is there a way to automatically delete any row that has a 0 in both
of 2 specified columns (i.e. BF and BG)?

Thanks for any help.


---
Message posted from http://www.ExcelForum.com/



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

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