Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete zero value rows

Status
Not open for further replies.

izzyq

MIS
Mar 13, 2002
38
CA
How would I go about geting a macro that will allow me to delete any row in a range that contains a zero value. I have a range "A6:C1003" and there are rows where all three columns contain zeros which I need to delete. For example columns A,B and C row 45, 48, 98 contain zeros.

The rows which contain zeros is not always constant so I need to have it somehow loop through the range and remove the rows completely.

Thanks Help Me Obi Wan Kenobi, You're My Only Hope.
 
You can try this:

Sub ClearZeroRows()
Dim intFirstRow As Integer
Dim intLastRow As Integer
Dim intRow As Integer
Dim strRow As String

intFirstRow = 6
intLastRow = 1003

intRow = intFirstRow
Do
strRow = CStr(intRow)
If Range("A" & strRow).Value + Range("B" & strRow).Value + Range("C" & strRow).Value = 0 Then
Rows(strRow & ":" & strRow).Delete Shift:=xlUp
intLastRow = intLastRow - 1
Else
intRow = intRow + 1
End If
Loop Until intRow > intLastRow
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top