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

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

you forgot an underscore after the first line, but other than that the code
looks legit, but for some reason i get an mismatch error 13.

"StumpedAgain" wrote:

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