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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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?
 
Upvote 0

Forum statistics

Threads
1,222,142
Messages
6,164,167
Members
451,880
Latest member
2da

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