Pause macro then resume macro

RHB1987

New Member
Joined
Dec 9, 2010
Messages
34
Hello,

I am looking for a code that will pause a macro and then resume with the macro when I am done doing changes.
I have looked everywhere on the internet, also on this website, but I do not seem to get the answer I am looking for.
I hope anyone can really help me with this. The Excel version I use is from 2010.

I have a macro with a lot of code. At a certain moment the macro has to be paused.
The necessary changes have to be made to the active worksheet and then a button with "resume" should be pressed so the macro will continue.
These changes are never the same and cannot be put into code.
Wait is not an option, because sometimes it might be that the changes just take 20 seconds and sometimes up to 5 minutes.
But I cannot wait 5 minutes to resume with the macro.

I have found some code and it works, but it stops after the Resume button is pressed. It does not continue with the rest of the code.
This is the code I use, this is a userform called ResumeForm
Code:
Private Sub ResumeButton_Click()
continue = True
Unload Me
End Sub

This is put into the macro where I want it to pause:
I have declared continue as a bolean.
Code:
Public continue As Boolean
and in the macro this is the code used:
Code:
continue = False
ResumeForm.Show (vbModeless)
Do
DoEvents
Loop Until continue = True

When I click on the Resume button the macro stops and does not resume with the rest of the code.

I have read about cutting the macro in two parts, but I do not know how to do that.
Also are many variables declared, I need these variables when I resume with the code.
I have also read that there is a way to declare these variables again, but I do not know how to do that.

I would really appreciate some good help. If you respond please do not give me vague suggestions, but please give me some code I can use. Please explain this so it is understandable what to do. I did not create the above code, I understand how it works, but I would not be able to write it myself.

The answers would be very helpful, not just for me, but for anyone who is looking for a good pause and resume VBA code.

Thank you very much on forehand!

Sincerely,
Richard
 
Last edited:
Hello again!

I just thought it would be easier for the user to only have to call up one macro then use the Resume button when finished with each part. There would have to be 3 macros to do the job, so I figured to not confuse the user, LOL!
But, if it has to be 3 separate ones, then that's what it will be. I just kinda hate to not use the Resume button after you spent so much time getting it to work. It's really COOL!

(If something occurs to you that would let us use the Pause-Resume, please let me know. Meanwhile, we'll just work with 3 macros)

Anyway, thanks for all your help!

Jenny

No problem! You could also just make 3 buttons for your 3 macros and a user guide in a tab to make it clean ;)
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
No problem! You could also just make 3 buttons for your 3 macros and a user guide in a tab to make it clean ;)
I just called them POsApproachingShipdate1, 2, and 3.

Now I just have to figure out how to have it look down column E on "NEW PULL" and if it finds a match in column C of "FBO LIST" then paste E from "FBO LIST" in column C of "NEW PULL". I've got it to find the match on "FBO LIST" but it considers i - in this case row 10 of "NEW PULL" to also be row 10 of "FBO LIST". I'm working on how to tell it to use the row from "FBO LIST" that corresponds with the match. Grrrrr LOL!

Jenny
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top