Error message display

sujittalukde

Well-known Member
Joined
Jun 2, 2007
Messages
520
I am using the folllowing code to update web qwery. Since the site needs password so I use "Remenber me" in the site so that I do not need to log in again. But the same expires after some days and I need to relog in. Then the code executes an error. I want that instead of showing the error msg, the code shall show following msg
"Please visit the web to re log in". Where this message is to put in the code? Someone should please help!
Code:
Sub Update()
    Application.ScreenUpdating = False
    Application.DisplayStatusBar = True
    Application.StatusBar = "Please wait while updating..."
    Application.Wait Now + TimeValue("00:00:02")
    Sheets("Web").Select
    Range("A40").Select
    Selection.QueryTable.Refresh BackgroundQuery:=False
    Sheets("TOP").Select
    Application.StatusBar = False
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

sujittalukde

Well-known Member
Joined
Jun 2, 2007
Messages
520
I have modified the error handler message as shown below, but it is showing the Message every time the code completes its task, ie evenif there is no error
Code:
Sub Update()
    Application.ScreenUpdating = False
    Application.DisplayStatusBar = True
    Application.StatusBar = "Please wait while updating..."
    Application.Wait Now + TimeValue("00:00:02")
On Error GoTo endo
    Sheets("Web").Select
    Range("A40").Select
    Selection.QueryTable.Refresh BackgroundQuery:=False
    Sheets("TOP").Select
    Application.StatusBar = False

endo: MsgBox "Please relogin the web"
End Sub

Please help me in handling the error and message box?
 

Forum statistics

Threads
1,181,404
Messages
5,929,750
Members
436,687
Latest member
Glass of Gin

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
Top