View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Fredrik Wahlgren Fredrik Wahlgren is offline
external usenet poster
 
Posts: 339
Default Macro to Delete Row


"Tom Fortune" wrote in message
...
The following code does not seem to work in Excel 2000. It worked in

Excel
XP. I need to evaluate a cell, starting at D2, and then delete the row if
the cell is empty stopping at the last row. The column being evaluated
contains dates so if the item is not closed the cell is empty.

Dim TestColumn As Long
Dim cRows As Long
Dim i As Long

TestColumn = 1
cRows = Cells(Rows.Count, TestColumn).End(xlUp).Row
Range("D2").Select

For i = 2 To cRows
If ActiveCell.Value 0 Then Selection.EntireRow.Delete
Next i

--
Sincerely,
Tom Fortune


Wher does your code fail?

try somthing like

On Error GoTo ErrorHandler
Dim TestColumn As Long
Dim cRows As Long
Dim i As Long

TestColumn = 1
cRows = Cells(Rows.Count, TestColumn).End(xlUp).Row
Range("D2").Select

For i = 2 To cRows
If ActiveCell.Value 0 Then Selection.EntireRow.Delete
Next i
exit Sub

ErrorHandler
MsgBox Err.Message

/Fredrik