Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Message Box if Error
I have a macro that pulls back info from a web site. I just refresh
the code to periodically update, sometimes this web site is down and my code returns an error. How would I include a message box if such an instance occurs with a simple message "web site down, info not updated"? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Message Box if Error
Sub errorr()
myError = True If myError Then MsgBox ("something bad happened") End If End Sub -- Gary''s Student - gsnu2007 "Sean" wrote: I have a macro that pulls back info from a web site. I just refresh the code to periodically update, sometimes this web site is down and my code returns an error. How would I include a message box if such an instance occurs with a simple message "web site down, info not updated"? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Message Box if Error
Thanks Gary, but how does it know there is an error? After each
'action' of my code, how do I say "if error, then run my sub error" and cancel the balance of the code? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Message Box if Error
Hi,
You can do this: 'Place this above the line you get the error On Error Goto ErrorHandler Somewhere within the same sub place this ErrorHandler: If Err.Number = 10(you need to make this the error number you get) msgbox "Error" end if -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200710/1 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Message Box if Error
Thanks for that, so I can 'sprinkle' my code with - On Error Goto
ErrorHandler i.e. at all major actions? The error number, is this the type "Run Time error 1004" etc? Thanks again |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Show Message Box if Error
Yes, you can.
The ErrorHandler: is a goto line, this can be changed and you can create others ie On Error Goto ErrorHandler1 ErrorHandler1: If Err.ect On Error Goto ErrorHandler2 ErrorHandler2: If Err.ect Crowbar Sean wrote: Thanks for that, so I can 'sprinkle' my code with - On Error Goto ErrorHandler i.e. at all major actions? The error number, is this the type "Run Time error 1004" etc? Thanks again -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200710/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error message - PivotTable will not fit on sheet. Show as much as | Excel Worksheet Functions | |||
ProgramEntries.Show 1 causes errors...but no error message given? | Excel Programming | |||
replace VBA run-time error message with custom message | Excel Programming | |||
changing the message in an error message | Excel Worksheet Functions | |||
show message | Excel Programming |