I have a VBA problem - I want to do exactly what was being solved in this thread:
Delete Entire Row if Cells is Zero in Column J VBA
However instead of deleting the entire row based on ONE column being zero (in this example, J), I want to delete entire rows which contains zeroes in all cells in a specified range (columns D through AC). For example, if D2 thru AC2 all contain zeroes, then row 2 should be deleted from the sheet. Also, let's say D2 thru Y2 contain zeroes, but Z2 thru AC2 contain numeric values other than 0. In this case, I would NOT want to delete row 2 from the sheet.
Please let me know how I can change the macro to specify an entire range of columns instead of just one column.
This is the code I took from the above thread (right now it removes all rows where there is a zero in the 10th column):
Sub Maybe3()
Dim x, i As Long
Application.ScreenUpdating = 0
With Sheets("Sheet2").Cells(1).CurrentRegion.Columns(10) '<----- Change to actual sheet name
x = .Value
For i = 1 To UBound(x, 1)
If x(i, 1) = 0 Then x(i, 1) = vbNullString
Next
.Value = x
.SpecialCells(4).EntireRow.Delete
End With
End Sub
Display More
I'm new to this website so don't know how to reach out. If you can message me please do. Thank you!