View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Nikki Nikki is offline
external usenet poster
 
Posts: 184
Default Code to stop a Macro

Thanks - I get a pop up box between each sheet. You are the best.

"Lars-Åke Aspelin" wrote:

If the sheet or sheets that you want to skip are always the at the end
of the sequence of sheets you can put the following code between each
of your twelve code segments.

If MsgBox("Skip the remaining sheets?", vbYesNo, "Checkpoint") =
vbYes Then
Exit Sub
End If

If you want the possibility to skip single sheets in the middle of the
sequence you could try this code instead:


If MsgBox("Skip the next sheet?", vbYesNo, "Checkpoint") = vbNo Then
---------- your code goes here ----------------
End If

If MsgBox("Skip the next sheet?", vbYesNo, "Checkpoint") = vbNo Then
---------- your code goes here ----------------
End If

If MsgBox("Skip the next sheet?", vbYesNo, "Checkpoint") = vbNo Then
---------- your code goes here ----------------
End If

and so on for all your twelve sheets.

You should also include some more useful information than just "next
sheet" in the prompt, e.g. the sheet name.


Hope this helps / Lars-Åke


On Fri, 2 Jan 2009 10:23:01 -0800, Nikki
wrote:

I have 12 codes similar to the one below. Before moving to the next (sheet)
in the code I would like to stop the Macro with a Message Box and ask if I
want to resume. Basically a breakpoing between each sheet. I could update one
sheet and continue or not move to the next sheet. I am sorry for not
explainging very well. I am new to using the code. Thanks so much for your
patience....

Sheets("RETENTION_TermVol").Select
Selection.FormulaR1C1 = _

"=VLOOKUP(RC[-9],'MonthlyOpsMetrics_Upload_to_ActualDataFile.xls'! OPSDATALOAD,7,0)"
Selection.Copy
Range(Selection, Selection.Offset(10, 0)).PasteSpecial
Selection.End(xlDown).Select
Application.CutCopyMode = False
Selection.FormulaR1C1 = _

"=VLOOKUP(1006,'MonthlyOpsMetrics_Upload_to_Actua lDataFile.xls'!OPSDATALOAD,7,0)"

"Lars-Åke Aspelin" wrote:


Sorry, but too much guessing what you really want to accomplish is
needed.
Why do you want to stop the macro anyway?
From you problem description the only information given is that in
some months you have to update 8 sheets and in some months you have to
update 12 sheets. That can be solved using IF statements.

Please give a more detailed description of your problem.

Lars-Åke

On Fri, 2 Jan 2009 09:55:02 -0800, Nikki
wrote:

but what if I want it to resume after exiting?

"Lars-Åke Aspelin" wrote:

On Fri, 2 Jan 2009 09:40:01 -0800, Nikki
wrote:

Can anyone please tell me what code would work to stop a Macro when updating
multiple sheets? I have about 12 sheets and only need 8 updated every month;
the other 4 are only required to be updated every 3 months.

Thanks

Try this:

Exit Sub

Hope this helps / Lars-Åke