+ Reply to Thread
Results 1 to 19 of 19

pause macro and show message box to click on it to continue

  1. #1
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    pause macro and show message box to click on it to continue

    Hi All,

    I have some code that runs, but needs to be paused for a moment and then continue when a user clicks a button on message box that appears.
    so it could be like below:

    code runs
    code comes to a pause point and shows message box
    user clicks message box ok button when he finish
    code continues

    This will be part of a loop.

    I was googeling with no luck. the only thing I found was the below that gives me an error when clicking on it (is like getting a second continue with code button)

    Please Login or Register  to view this content.
    any idea how to solve this?

    Greetings.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: pause macro and show message box to click on it to continue

    How you declared RetVal?


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: pause macro and show message box to click on it to continue

    Howdy,
    If I understand the issue, simply insert a msgbox "enter comment here" command in your loop and the execution will stop there, when the user clicks OK the next statement commences.

    Or have I missed a point here???

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  4. #4
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi,
    I did not, I'm new to all of this and have no clue.
    Let's say I have below loop. I would like it to pause before the next i. How should I declare it and put the message box in the correct place?

    Please Login or Register  to view this content.
    Greetings.

  5. #5
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: pause macro and show message box to click on it to continue

    a macro will pause when a message box is initiated anyway and continue when it is closed so just
    Please Login or Register  to view this content.
    inside the loop would work
    Sub Reputation()
    Dim Problem as Variant
    Dim Reputation as Integer
    For Each Problem in Forum.Threads
        If Problem.Title = "*[Solved]*" and Solver.Name = "Leon V (AW)" Then Reputation = Reputation + 1
    Next Problem
    End Sub

  6. #6
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi Jmac1947,

    That is the idea. I need to stop the loop so it will not run untill I say so.

    Greetings.

  7. #7
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi Leon V,

    The message box really stops it, when I click OK, I get the message box from excel: Code execution hs been interrupted > continute, end, debug, help.
    This is kind of annoying that it brings me to the message box from excel and need to press again continue.
    Any solution for not getting this one?

    Greetings.

  8. #8
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi all,

    I created my loop, but it misses something.
    It should take the cell in column 10, and then when looping the next, the row below the previous one.

    Please see my code and tell me where I go wrong, please ;-)

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: pause macro and show message box to click on it to continue

    that usualy turns up when you Ctrl+Break out of code not sure why it would turn up here. does your over arcing code have some ontime events in it?

  10. #10
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi,

    there was no break in the code, everything runs fine. I wanted to pause the code on that point. It kind of works with the double pressing a button, but the loop does not work the way it should.
    How can I tell the loop to go to the next row in column 10? (my expirience with loops is minimal).

    Greetings.

  11. #11
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi,

    I found some code for the loop, but get strange results as it does copy nothing from column 10. the value that it has to copy is: CJ 22945/2014 (so I don't know if it has to do with the way the text is)
    can some one look at the below code and tell me where I go wrong?

    Greetings.

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi,

    It seems that the macro paste in random numbers, not the one from the current cell that has value of i in the loop.

  13. #13
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi all,

    I guess I think I know what is wrong. I changed the loop code to below. Now it will pass "2" to the field in the website. It turns out that the value of i is 2. I need the value of the cell that the loop is in.
    How can I change that part to make it work? please ;-)

    Please Login or Register  to view this content.

  14. #14
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: pause macro and show message box to click on it to continue

    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  15. #15
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    328

    Re: pause macro and show message box to click on it to continue

    i is just a number.
    are you trying to reference the cell at row i?
    Please Login or Register  to view this content.

  16. #16
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: pause macro and show message box to click on it to continue

    That's not the same code. Please post the code in its entirety.

  17. #17
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi all,
    The solution from Solus did work out ;-) I just did not come up with the idea that I needed to pass the column value too ;-)
    So Solus, THANKS A LOT ;-)

    Now that the macro runs nice, I still have a little thing I would lilke to get rid of. The Internet explorer save as dialog box opens every time and I need to click 2 times to get rid of it (once for the chose folder and second time for saving it).
    Is there a way to block this while the macro runs? it really slows things down :-(

    All of you BIG THANKS ;-)

    Greetings.

  18. #18
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi Solus,

    If I now could get rid of the error when I come to the message box and it does not give the stupid error message, would be great + the evil IE save as dialog box

    Here is the full code:

    Please Login or Register  to view this content.

  19. #19
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: pause macro and show message box to click on it to continue

    Hi all,

    I found the below link:
    http://www.mrexcel.com/forum/excel-q...cations-3.html

    And wanted to know if someone can help me in understanding which part I need to take from the code to stop the annoying save as dialog from windows. The file name that is downloading has unique name. All I need is that it uses the folder name that is in the cell to the left of the one the loop is current on. So if it happens to be that the loop is in row 25, then next to it is the folder name and that should be used to save the file in.

    Greetings.

+ 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. Pause Macro, move to another cell, continue macro execution
    By slotcardan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2014, 08:23 PM
  2. Error message is To Continue saving as a micro – free workbook, Click Yes”.
    By amarendra19 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2011, 08:34 AM
  3. Pause macro, select file, continue macro
    By DamienC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-18-2008, 07:18 AM
  4. [SOLVED] Can you pause a macro in excel to input data and continue?
    By Hutch in forum Excel General
    Replies: 1
    Last Post: 05-05-2006, 01:20 PM
  5. Macro Pause, show message, continue
    By davegb in forum Excel General
    Replies: 3
    Last Post: 02-11-2005, 01: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