Error Handler Logic required

Tejas Kore

Board Regular
Joined
Nov 2, 2017
Messages
72
Office Version
  1. 365
Platform
  1. Windows
Hi All,


I am trying to automate a mail sending process. I want to catch a particular error that is when someone's name in 'To' or 'CC' field is not resolved.
Below is the code snippet -
.
.
answer = MsgBox("To continue select YES", vbYesNo)
If answer = vbYes Then
On Error GoTo ErrCatcher
ML.Send 'sending
'Exit Sub
ErrCatcher:
MsgBox "Resuming Execution"
Else
Mws.Cells(j, 9).Value = "Not Send"
End If
.
.


Here I am trying to display user the mail template for mail which is about to go. So when user is ready then he/she can select 'Yes' or 'No' through the message box. If the user selects 'Yes' then 'ML.send' gets executed and here I want to catch the error for name resolution if it occurs.


Right now this 'ErrCatcher:' will be executed in any case i.e. whether error occurs or not.
My focus is to catch error for name resolution and handle it appropriately. Any suggestions/solutions are welcome.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hello Tejas Kore,

Try this...

Code:
Sub ErrTest()


    Dim answer As Integer
    
        On Error GoTo ErrCatcher
        
        answer = MsgBox("To continue select YES", vbYesNo)
        If answer = vbYes Then
            ML.Send 'sending
            MsgBox "Resuming Execution"
        End If
                
        On Error GoTo 0
        
                
ErrCatcher:
    If Err <> 0 Then Mws.Cells(j, 9).Value = "Not Send"


End Sub
 
Upvote 0
Thanks a LOT !! Leith Ross. Your solution is running absolutely fine :)
 
Upvote 0
Hello Tejas Kore,

You're welcome. Glad I could help.
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top