View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
StumpedAgain StumpedAgain is offline
external usenet poster
 
Posts: 192
Default Jarek, almost there...

OK so here's the problem: When you delete a cell, the cell below it takes
its place. Because the program has already looked at that cell, it doesn't
catch the entry that has taken its place and moves on to the next cell.

total metal
ITEM
0
total board

becomes:

ITEM
total board

To fix this I recommend using clear contents instead of delete. See the
following:

Sub delete()

For Each Cell In ActiveSheet.UsedRange
If Cell Like "total board" Or Cell Like "total metal" Or Cell Like "ITEM" Or
Cell Like "0" _
Or IsNumeric(Cell) Or Cell.HasFormula _
Or IsError(Cell) Then
Cell.ClearContents
End If
Next Cell

End Sub

"Rick Rothstein (MVP - VB)" wrote:

For Each Cell In ActiveSheet.Cells


Perhaps using...

For Each Cell In ActiveSheet.UsedRange

instead of...

For Each Cell In ActiveSheet.Cells

would involved processing less cells?

Rick