Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop to trap error goes on True or False?

Status
Not open for further replies.

neiljabba

IS-IT--Management
May 22, 2003
86
0
0
GB
Hello all

The following code works as two individual parts, one to trap the errors and one to display the "are you sure" type message.

Sub checkit()
Dim cont As range

For Each cont In range("stuff2")
On Error Resume Next
iAnswer = MsgBox("A value has been deleted or removed from the central workbook. Please click OK to delete or Cancel if you are unsure.", vbOKCancel)
If iAnswer = vbOK Then range("stuff2").SpecialCells(xlFormulas, xlErrors).EntireRow.Delete Else End
Next cont
On Error GoTo 0
End Sub



Unfortunately as one code it doesnt trap errors it just launches into the msgbox irrespective of any error present.

I need this to obviously trap the error and make sure the user wants to go on and delete the row.

It is set to go through a named range stuff2

Perhaps I have mixed too much together without considering each bit of codes effect on the other.

Anyones help would be great.


Many thanks in advance

Neil
 
If you want to trap the error you will need to get rid of the "On Error Resume Next", you are telling the procedure to just continue regardless of what happens.

 
How do I trap the error then? I got that code of this forum.

I need to trap the #REF! error.

Thanks

Neil
 
Cheers

Ill give it a try on Monday and let you know

Have a good one.

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top