Deleting Rows in Excel


Posted by CW on October 25, 2001 7:01 AM

Hi all,

Can anyone help me? new to VBS and trying to get a script that will delete all rows that have all zeros for example:
A B C D
1 2 1 8
0 0 0 0 **
1 4 5 8
0 0 0 0 **
I need to delete these **
Please help if u can!!!

Posted by EDDIE G on October 25, 2001 7:09 AM

Will this work?

Sub Rowswithzeros
Do While Selection <> ""
If Selection.value = 0 Then
Selection.EntireRow.Delete
Else
Selection.Offset(1, 0).Select
End If
Loop
End Sub

Posted by conor on October 25, 2001 7:25 AM

nah, tried it and it dont work, once there deleted need to move them up so its nice and tidy!!!!
thanks anyway, wanna try again???



Posted by Stan on October 25, 2001 8:21 AM

Try This

Conrad

Eddie's code needs just a little tweaking. Is this what you were looking for:

Sub Rowswithzeros()
Do While Selection <> ""
If Selection.Value = 0 Then
Selection.EntireRow.Delete shift:=xlUp
Else
Selection.Offset(1, 0).Select
End If
Loop
End Sub