View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dennis Tucker Dennis Tucker is offline
external usenet poster
 
Posts: 140
Default delete rows which have a one in them

Try this.

Sub Macro1()

' count down through the rows(from bottom to the top)
For MyRow = Worksheets("Sheet1").UsedRange.Rows.Count To 2 Step -1
' check column H for a "1"
If Worksheets("Sheet1").Range("H" + CStr(MyRow)).Value = "1" Then
' select the row
Rows(CStr(MyRow) + ":" + CStr(MyRow)).Select
' delete the row & shift data up
Selection.Delete Shift:=xlUp
End If
Next MyRow

End Sub


"kyle" wrote in message
...
i've got this code built that will delete a row if there is a one in
column h
but it's not working

sub delete()

finalrow = celss(rows.count, 1).end(xlup).row

for i = finalrow to 2 step -1
if cells(i, 8) = 1 then
cells(i, 1).entirerow.delete
endif
next i
end sub

it doesn't work, what do you think is wrong?