+ Reply to Thread
Results 1 to 8 of 8

Yes/No Message box keeps looping

  1. #1
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Yes/No Message box keeps looping

    Hi all,

    I have created the below coding in a sheet

    Please Login or Register  to view this content.

    The code works great, the only problem is that it keeps looping back to the Yes or No message box rather than completing the tasks and returning back to the sheet. It will probably be a simple thing but, having not used VBA for a while I am a little stuck so any help would be appreciated.
    Last edited by elleb; 06-23-2018 at 04:33 PM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Yes/No Message box keeps looping

    You need to shut off events:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Yes/No Message box keeps looping

    Another method:
    Please Login or Register  to view this content.
    The problem is that without specifying what the target is, in your code whenever the sheet changes and B2 still = 1 then the code just fires again.

    The above code will fire only when the sheet change happens to B2. Not ideal in all instances, and we certainly don't have enough info about your workbook in order to say if this approach would be suitable or not, but adding it for the sake of info.

    BSB

  4. #4
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Re: Yes/No Message box keeps looping

    Hi guys,
    Thanks for the quick replies. The coding worked to hide and clear the sheets but won't work to expand it again.

    I apologise for being vague I was hoping with a little nudge in the right direction it might jog my memory and I could figure out the rest. So, within this sheet the users can enter any number between 0 and 20, if they enter 0 or it is blank then everything is shown, if they enter more than 20 an error will show up to advise that they can only enter a value up to 20. Lastly, depending on what value they enter between 1 and 20 will cause the sheet to hide/unhide certain columns and clear the data in any columns that are due to be hidden.

  5. #5
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Yes/No Message box keeps looping

    It works for me. Enter 1 in B2 and columns are hidden, change it to 0 and they're unhidden.

    Doesn't do anything if you enter 2, 3, 4 etc. as the snippet of code provided only deals with 0 or 1.

    BSB

  6. #6
    Forum Contributor
    Join Date
    11-07-2014
    Location
    UK
    MS-Off Ver
    2010
    Posts
    126

    Re: Yes/No Message box keeps looping

    Hi,

    I've come out of the workbook and gone back in and it is now working correctly, not sure what was wrong but, thank you both so much for the help.

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Yes/No Message box keeps looping

    Happy to help. Glad it's sorted

    BSB

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Yes/No Message box keeps looping

    You're welcome- glad you got it and thanks for the rep!

+ 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. Replies: 1
    Last Post: 05-30-2018, 12:17 PM
  2. Adding an input message to each cell to bring back corrsponding message
    By Nic31 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2014, 09:28 AM
  3. [SOLVED] Stop Message Box looping when OK is selected
    By connieb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 04:40 PM
  4. Do Until Looping (not looping through all other columns)
    By orle8050 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2013, 10:37 AM
  5. [SOLVED] How to pop up a warning message before any Excel automatic update link reminder message
    By billj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2013, 10:41 AM
  6. [SOLVED] Intercept/replace standard 'cell protected' message with my own message?
    By KR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2006, 10:35 AM
  7. [SOLVED] looping alarm message, running in the background
    By claes, singapore in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2005, 11:06 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