Consulting

Results 1 to 5 of 5

Thread: Solved: Error Handling Help

  1. #1

    Solved: Error Handling Help

    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?

  2. #2
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    [vba]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
    [/vba]
    Something like that
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is err.Number and err.Description, not err.Num and err.Name.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Mentor
    Joined
    Feb 2009
    Posts
    493
    Location
    Yeah sorry about that. Had just woke up.
    -----------------------------------------
    The more you learn about something the more you know you have much to learn.

  5. #5
    it works. thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •