+ Reply to Thread
Results 1 to 8 of 8

Run code with MsgBox Response

  1. #1
    Registered User
    Join Date
    08-02-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    44

    Run code with MsgBox Response

    I found one instance where code was run within the response to a msgbox.
    I tired to run some simple code within the response from a message box,
    for example between IF Response = vbYes and Exit Sub. This may not be able to be
    done

    Please Login or Register  to view this content.
    Thanks to anyone who may shed some light on this issue, hopefully simple????
    Thanks in Advance!
    Sgt Rock (Dallas)

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Run code with MsgBox Response

    Assuming you want to color cell A1:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-02-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Run code with MsgBox Response

    Most courteous of you "stnkynts" thanks...let me copy and study and see if I can get this to work....
    Thank you again, will be back in a short....
    Sgt Rock (Mort in Dallas)

  4. #4
    Registered User
    Join Date
    08-02-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Run code with MsgBox Response

    I actually used the vbNo route for that is where the color problem is coming in.
    In words, if any of the cells in Range F27:H27 have a value > 100 use Interior.ColorIndex = 6 (yellow)
    This is a routine within a larger sub.
    Here's the revised code, but when 104 was entered into cell F27 (auto calculated) the interior color did not change to yellow??
    Not sure what I am doing wrong - hopefully easy to spot in the code?

    NOTE: ALL THE MESSAGE BOXES POP-UP AND WORK PERFECTLY!!

    Note that I am looping through the cells for there may be a number in each, and am checking if it > 100 or not.
    Thanks a bunch!!!
    Sgt Rock (Mort in Dallas)

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    227

    Re: Run code with MsgBox Response

    Quote Originally Posted by Sgt Rock View Post
    I actually used the vbNo route for that is where the color problem is coming in.
    In words, if any of the cells in Range F27:H27 have a value > 100 use Interior.ColorIndex = 6 (yellow)
    This is a routine within a larger sub.
    Here's the revised code, but when 104 was entered into cell F27 (auto calculated) the interior color did not change to yellow??
    Not sure what I am doing wrong - hopefully easy to spot in the code?

    NOTE: ALL THE MESSAGE BOXES POP-UP AND WORK PERFECTLY!!

    Note that I am looping through the cells for there may be a number in each, and am checking if it > 100 or not.
    Thanks a bunch!!!
    Sgt Rock (Mort in Dallas)

    Please Login or Register  to view this content.
    Not sure what's the issue with you, that code is working perfectly fine for me.

  6. #6
    Registered User
    Join Date
    08-02-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Run code with MsgBox Response

    May I say lucky you....
    Simplistically, the message appears that says "The PBT 100 pound threshold...." - I click OK - at that point I enter a letter (m, p, or o) into column which in turn, will place a number at the bottom of another column.
    If the number is > 100 the background color should be yellow.
    Conceptually, what I am trying to accomplish is this - if the answer to a statement, i.e., message box is vbNo, then display a message (the PBT message above), after which I click OK, then code will run (that code is to color the cell interior if the value is > 100).

    I'm wondering what the flow of code is after one presses OK to a message box????

    You assistance is graciously appreciated....

    Sgt Rock (Mort in Dallas)

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Run code with MsgBox Response

    The flow of code is as you describe. Your code will colour cells in the active sheet, whichever that happens to be - is that correct?
    Remember what the dormouse said
    Feed your head

  8. #8
    Registered User
    Join Date
    08-02-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Run code with MsgBox Response

    I "think" I know the issue - I'm running the colorindex code BEFORE there is an entry in the range F27:H27
    Just did a test, another message box, "got here" and the flow does in fact pass on to the code:

    Please Login or Register  to view this content.
    I have to figure out how to run the code AFTER there is an entry in the range F27:H27.
    Thanks for our suggestion - most appreciated...
    Sgt Rock (Mort in Dallas)

  9. #9
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Run code with MsgBox Response

    If you want to run the code after there is an entry in range F27:H27 you will need to utilize the worksheet_change event. Something like this:

    Please Login or Register  to view this content.

+ 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] Worksheet does not become the active 1 using .Activate function based on MsgBox response
    By thelisa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2013, 04:55 PM
  2. Change code to require a Response
    By Aeneren in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-22-2012, 11:01 AM
  3. Slow workbook response until code break & reset
    By airrun in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-28-2008, 05:57 PM
  4. MsgBox response
    By Sunflower_Queen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2005, 05:08 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