+ Reply to Thread
Results 1 to 7 of 7

Error Handling: Creating code to display error messages

  1. #1
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Error Handling: Creating code to display error messages

    I'm struggling with one of my macros and I'm looking for some insight. There a hidden worksheet within my workbook that houses all the raw data that pulls onto my main summary page. If there's an error on my hidden "feeder" page, I want to display a message box that will inform the user that an error has occured in whatever column the error is located in. I was thinking about creating a line of code for each column that says if there's an error anywhere in this column, then display this message "(message here)", otherwise display nothing.

    I don't know how to use VBA to identify errors and then do something, so any help would be appreciated. I guess what I'm trying to do is similar to the iferror function, only I want to use VBA to display a specific message box. Thank you in advance for everyone's time.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Error Handling: Creating code to display error messages

    It would be very helpful if you can post the code that you have to "pull" the raw data. Also explain in more detail what do you mean by error?

  3. #3
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Error Handling: Creating code to display error messages

    Millz,

    Certainly, and thank you for your interest. I have posted a simple example of my workbook to display my intention. I've had to remove some things in order to post online, but the general idea is simple enough. The tab reading "Feeder Table (Hidden)" contains various formulas in F15:L15. I'd like to create a macro that, when run, looks at that range, and if there's any type of error (for example, #DIV/O, etc.), the macro will display a MsgBox that says 1) an error exists 2) the name of the column heading. So for example, if the formula in cell H15, an average, has no inputs, it will return #DIV/0. When the macro runs, I would like it to identify that an error exists in H15, then return a message to the user saying "An error has occurred in the Account field. Please investigate" - or something similar.

    Hopefully I've provided enough information to solve this issue. Again, thanks to all for their time and advice.

    -Student1990ErrorID_MsgBox_TEST.xlsm

  4. #4
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Error Handling: Creating code to display error messages

    Hi Student1990

    Perhaps something like this
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Error Handling: Creating code to display error messages

    jaslake,

    Thank you for your response. I've been playing with this, and I keep getting runtime error 1004: "No cells were found" when there aren't any errors in the range. How can I modify this code so that the macro does nothing/displays nothing if no errors are found?

  6. #6
    Forum Guru jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Error Handling: Creating code to display error messages

    Hi Student1990

    Try this
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-25-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Error Handling: Creating code to display error messages

    That did the trick. Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Dealing with Application Messages when running VBA - Error Handling
    By JungleJme in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-21-2012, 10:21 AM
  2. Creating Error Messages in MS Excel
    By Mike87 in forum Excel General
    Replies: 11
    Last Post: 04-21-2008, 06:44 PM
  3. error handling when creating a file
    By mwc0914 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2006, 03:11 PM
  4. Error Handling - On Error GoTo doesn't trap error successfully
    By David in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-16-2006, 02:10 PM

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