Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 454
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error message - PivotTable will not fit on sheet. Show as much as Donna W Excel Worksheet Functions 2 June 27th 07 04:20 AM
ProgramEntries.Show 1 causes errors...but no error message given? [email protected] Excel Programming 2 May 9th 07 05:34 PM
replace VBA run-time error message with custom message BEEJAY Excel Programming 13 July 14th 06 03:59 PM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM
show message Mark Kubicki Excel Programming 6 December 19th 03 01:54 PM


All times are GMT +1. The time now is 03:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"