+ Reply to Thread
Results 1 to 10 of 10

How to do Error handling for an Excel vba code?

  1. #1
    Registered User
    Join Date
    05-21-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    75

    Post How to do Error handling for an Excel vba code?

    Hi All,

    Can anyone help me how to do error handling with a sample code?

    Thanks in advance.

    Regards
    Kumar

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to do Error handling for an Excel vba code?

    Something like

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-21-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: How to do Error handling for an Excel vba code?

    Hi Kyle,

    Thanks for you once again responding in this post also.

    Actually I have some doubts on this concept.

    ->Is it enough to write like what you have sent.

    What about try , catch concept in this Excel VBA.

    Regards
    Kumar

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to do Error handling for an Excel vba code?

    Try catch doesn't exist in vba

  5. #5
    Registered User
    Join Date
    05-21-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: How to do Error handling for an Excel vba code?

    Kyle,

    Thanks for that.

    As per your given handler.I will get only the message of the error.

    1->Along with that , Is it possible the error occurred in which line?

    2->Is it possible to provide our custom messages?

    Regards
    Kumar

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to do Error handling for an Excel vba code?

    1. Not by default - I believe there are addins which can do this.
    2. You can put whatever you like in a messagebox

  7. #7
    Registered User
    Join Date
    05-21-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: How to do Error handling for an Excel vba code?

    Kyle,

    What about
    1. Error.HelpContext
    2. Error.HelpFile
    3. Error.LastDllError
    4.Error.Raise
    5 Error.Source

    Regards
    Kumar
    Last edited by ravikumar00008; 07-25-2012 at 11:45 AM.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to do Error handling for an Excel vba code?

    What about doing some research?

    This site helps people who have issues, it isn't, nor could it be a comprehensive guide to learning all things VBA. Try having a google, there's loads out there - Chip Pearson's site will cover most of what you want.

  9. #9
    Registered User
    Join Date
    05-21-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: How to do Error handling for an Excel vba code?

    Kyle,

    Sorry for that.

    There is a reason to ask you about those.
    Because when i use Error.Number in a MsgBox , It is showing some number.Is it a line number or predefined code to identify that error?

    Regards
    Kumar

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to do Error handling for an Excel vba code?

    No, as I've already mentioned - you can't get the line number easily.

    It is the error id

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1