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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Delete blank or zero rows 2

Status
Not open for further replies.

vaneagle

Technical User
Apr 23, 2003
71
AU
Any ideas on how I can remove blank or zero rows??

Sorting is not an option.....
would prefer a marco option....

basically the data is such:

12345 ttt aaa ccc
0
56778 eee aaa qqq
(blank)
etc
 
Hello,

try this:

Code:
Sub emtyrowsdelete()

'--dimmensionieren---
    Dim spalte, zelle As String
    Dim zeile As Integer
    Dim isnullcounter As Integer
'--initialisieren---
    spalte = "A"
    zeile = 1
    isnullcounter = 0
            
'--und los gehts --
    While isnullcounter < 6
        zelle = spalte + CStr(zeile)
        Range(zelle).Select
        If IsNull(ActiveCell.Value) Or ActiveCell.Value = 0 Then
            isnullcounter = isnullcounter + 1
            Selection.EntireRow.Delete
        Else
            isnullcounter = 0
            zeile = zeile + 1
        End If
    Wend
End Sub

You can change the stop parameter &quot;isnullcounter&quot; in what you need.

Regards
Daniel
 
Hi
Here's another possibility. However this will not work if, for example, you have positive & negative values that cancel each other out (eg 1, 2, 3, -2, -4)

Code:
Sub ClearNilOrEmptyRows()
Dim lRow As Long
Dim lCnt As Long
lRow = Cells.Find(what:=&quot;*&quot;, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
For lCnt = lRow To 1 Step -1
    If WorksheetFunction.CountA(Rows(lCnt)) = 0 Or _
        WorksheetFunction.Sum(Rows(lCnt)) = 0 Then
    Rows(lCnt).EntireRow.Delete
    End If
Next
End Sub

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
Thanks very much guys!!

they worked!!!

A star for you both!![2thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top