View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
AKphidelt AKphidelt is offline
external usenet poster
 
Posts: 461
Default Macro loop problem

Try this

Sub RowDeletingMacro()

Do Until ActiveCell.Value = ""
If ActiveCell.Value = 0 Then
ActiveCell.EntireRow.Delete
Else ActiveCell.Offset(1,0).Activate
End If
Loop

End Sub

Start the activecell at the beginning of the column you want to check for 0.
Or if you want to run this sub numerous times put in
Range("YourStartingCell").Activate

lmk

"Ben" wrote:

Hello, I'm very new to writing macros with the Visual Basic editor, so I was
wondering if someone could help me figure out why nothing happens when I run
the following macro:

Sub RowDeletingMacro()

x = 10

Do While Cells(x, 1).Value < ""
If Cells(x, 1).Value = 0 Then
Cells(x, 1).Rows(x).Select
Selection.Delete Shift:=xlUp
End If
x = x + 1
Loop

End Sub


My goal with this macro is to delete all rows in my worksheet that have "0"
as an entry in the first column, and to skip over all of the rows that do not
have 0 as their first column entry. Any help would be greatly appreciated,
thanks very much,

Ben