+ Reply to Thread
Results 1 to 5 of 5

MsgBox is lazy or disobedient

  1. #1
    Registered User
    Join Date
    01-25-2014
    Location
    Minneapolis
    MS-Off Ver
    Professional Plus 2010
    Posts
    19

    Question MsgBox is lazy or disobedient

    Hi Excel Forum

    I thought I at least had a kindergarten type understanding of VBA, but something is tripping me up here and I suspect I shall deserve to be bopped on the head with a saucepan when the solution is explained to me.

    The following code searches Column A for a cell that contains a string equaling the one stored in drop_point. (Since I'm not experienced at VBA I'm putting this program together in baby steps and using MsgBox way too often just to make sure, at this point, that I'm working with the cells I think I am.)

    dp2_cell has already been declared as an Object; drop_point as a string, and dp_search and sheet1_row_counter as integers.

    The cell we're hoping to land on is A2. Indeed, when this code runs, things seem to stop happening when A2 is highlighted. That's the good news. However, since the "wrong" value is in A1, I expected to see a MsgBox pop up saying "Not it!" and thus for me to have to click its OK button before anything else moved forward. Instead what happens is, I see no MsgBoxes. Neither the "Not It" one when cell A1 is being checked, nor the "Found It!" one when A2 has been reached and everything else stops.

    What. The heck. Am I missing here.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    10-05-2014
    Location
    Regina, SK Canada
    MS-Off Ver
    Excel for Mac 11
    Posts
    330

    Re: MsgBox is lazy or disobedient

    MsgBox can be your friend.
    I would suggest using it to indicate your sub has reached this loop
    (If neither message is being printed by the IF, perhaps the IF is not being executed.)

    Please Login or Register  to view this content.
    Should those messages not appear, then your error is elsewhere, perhaps a logical error.

  3. #3
    Registered User
    Join Date
    05-11-2015
    Location
    Chicago, IL
    MS-Off Ver
    2013
    Posts
    27

    Re: MsgBox is lazy or disobedient

    It looks like your error is in variable naming.

    The second line of code:

    Please Login or Register  to view this content.
    The third line of code:

    Please Login or Register  to view this content.
    There's an extra underscore between "sheet" and "1".

    I would highly recommend using
    Please Login or Register  to view this content.
    in your macros, which would have helped you catch this error by letting you know that
    Please Login or Register  to view this content.
    was an undeclared variable.

  4. #4
    Registered User
    Join Date
    01-25-2014
    Location
    Minneapolis
    MS-Off Ver
    Professional Plus 2010
    Posts
    19

    Re: MsgBox is lazy or disobedient

    I TOLD you I was going to deserve a saucepan-to-the-head!!

    Thanks so much guys. Here I was, thinking, "Wow, I'm doing such a good job of explicitly declaring my variables, I don't even need to use Option Explicit!" (losing-game-show tuba sounds...)

  5. #5
    Registered User
    Join Date
    05-11-2015
    Location
    Chicago, IL
    MS-Off Ver
    2013
    Posts
    27

    Re: MsgBox is lazy or disobedient

    It happens to the best of us haha.

    Just remember that even on your BEST day,
    Please Login or Register  to view this content.
    is still better than you at finding typos

+ 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. Macro to capture MsgBox prompt to a string variable but ignore the MsgBox
    By BuglerDobbs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2015, 10:56 AM
  2. [SOLVED] Problem with VBA Editor uses lower case on some lines (ex. msgbox instead of MsgBox)
    By stubbsj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2013, 06:59 PM
  3. I'm lazy. There has to be a faster way to pull data & cross reference a worksheet, right?
    By colleendeborah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2013, 07:52 PM
  4. lazy gits
    By martindwilson in forum The Water Cooler
    Replies: 91
    Last Post: 02-11-2013, 05:35 AM
  5. [SOLVED] Simple question I'm too lazy to answer but still need some help on
    By Zerex71 in forum Excel General
    Replies: 3
    Last Post: 07-21-2006, 05:20 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