PDA

View Full Version : Solved: Error Handling Help



doctortt
04-20-2011, 08:57 PM
Hi,

My Excel program will throw out some errors like "run-time error 380:" And I would like Excel to show a msgbox to tell the user to change the values of the variables instead of throwing this run-time error message. Can someone please show me how to write such codes?

BrianMH
04-20-2011, 10:51 PM
sub test

on error goto errorhandler

'your code

exit sub

errorhandler:
if err.num = 380 then
msgbox("your message")
else
msgbox(err.name & ", " & err.num)
end if
exit sub

Something like that

Bob Phillips
04-21-2011, 12:12 AM
It is err.Number and err.Description, not err.Num and err.Name.

BrianMH
04-21-2011, 12:16 AM
Yeah sorry about that. Had just woke up.

doctortt
04-21-2011, 08:37 AM
it works. thanks.