Tim M.


I am trying to figure out why a macro runs slower in Excel 2003 vs. 2002 and narrowed it down to a function that deletes rows. This function is used numerous times and before this function is called a varying row is selected, then is processed in this function. I think the Selection.Delete command is causing the slowed performance but not sure why it is. Does anyone have a suggestion Up to 100 rows can be selected based upon the criteria.

CellCount = 0
For Each Cell In Selection
If Cell.Value = 0 Then CellCount = CellCount + 1
Next Cell
If CellCount = 0 Then Exit Sub
CellCount = CellCount - 1
ReDim DRows(CellCount) As Single
TicCounter = 0
For Each Cell In Selection
If Cell.Value = 0 Then DRows(TicCounter) = Cell.Row
If Cell.Value = 0 Then TicCounter = TicCounter + 1
Next Cell
Set DeleteRange = Rows(DRows(0))
DeleteRange.Select
For NCTS = 1 To CellCount
Set DeleteRange = Union(DeleteRange, Rows(DRows(NCTS)))
DeleteRange.Select
Next NCTS
DeleteRange.Select
Selection.Delete Shift:=xlUp