View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Catch Error in macro

Sub RowDelete(abc)
Worksheets(abc).Select
Columns("B:B").Select
On Error Resume Next
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
On Error goto 0

Range("A2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="=*!*", Operator:=xlAnd
On Error Resume Next
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
On Error goto 0
Selection.AutoFilter
End Sub

--
Regards,
Tom Ogilvy

"sa02000" wrote:


I have following macro that I am using to delete entire row which has
blank cells or cells with exclamation mark. How do I go about catching
the errors that might be generated. One error that I am running into is
when there are no cells with either blank or exclamation marks?

Sub RowDelete(abc)
Worksheets(abc).Select
Columns("B:B").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete

Range("A2").Select
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="=*!*", Operator:=xlAnd
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.EntireRow.Delete
Selection.AutoFilter
End Sub

Thanks, Jay


--
sa02000
------------------------------------------------------------------------
sa02000's Profile: http://www.excelforum.com/member.php...o&userid=27747
View this thread: http://www.excelforum.com/showthread...hreadid=533738