View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
kkknie[_50_] kkknie[_50_] is offline
external usenet poster
 
Posts: 1
Default specialcells method errors when criteria not found

In your specific case, resume to the next line on an error and if it i
error # 1004, exit the sub. If another error occurred (due t
something other than not finding a match, display it and exit th
sub).

Sub CleanCancelledChks()
Dim r As Range
With ActiveSheet
Set r = .Range(.Range("D2"), .Range("D" & _
Rows.Count).End(xlUp))
.Columns("D:D").AutoFilter Field:=1, Criteria1:="=*-*"
On Error Resume Next
Set r = r.SpecialCells(xlCellTypeVisible)
.AutoFilterMode = False
If Err.Number = 1004 Then
Exit Sub
Else
Msgbox "Error Occurred: " & Err.Description
Exit Sub
End If
r.EntireRow.Delete
End With
End Sub



--
Message posted from http://www.ExcelForum.com