PC Review


Reply
Thread Tools Rate Thread

Code to stop a Macro

 
 
Nikki
Guest
Posts: n/a
 
      2nd Jan 2009
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
 
Reply With Quote
 
 
 
 
Lars-Åke Aspelin
Guest
Posts: n/a
 
      2nd Jan 2009
On Fri, 2 Jan 2009 09:40:01 -0800, Nikki
<(E-Mail Removed)> 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
 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      2nd Jan 2009
For a meaningful answer you should post the code you are using. Otherwise,
the respondent will have to guess what you are doing and write lengthy
explanations about why they are making the suggestions that they do make.

"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

 
Reply With Quote
 
Nikki
Guest
Posts: n/a
 
      2nd Jan 2009
but what if I want it to resume after exiting?

"Lars-Ã…ke Aspelin" wrote:

> On Fri, 2 Jan 2009 09:40:01 -0800, Nikki
> <(E-Mail Removed)> 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
>

 
Reply With Quote
 
Lars-Åke Aspelin
Guest
Posts: n/a
 
      2nd Jan 2009

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
<(E-Mail Removed)> 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
>> <(E-Mail Removed)> 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
>>


 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      2nd Jan 2009
That was pretty much the best answer Lars-Ã…ke could give you given you
posted nothing useful for him to look at. If you have a question as to how
code should work, post the code you are using (working or not) so we can see
what it is you are attempting to do and how the changes you requested might
be made to fit into it; otherwise we have no idea what you currently doing
or trying to do.

--
Rick (MVP - Excel)


"Nikki" <(E-Mail Removed)> wrote in message
news:E69CA951-0089-4ED7-AD19-(E-Mail Removed)...
> but what if I want it to resume after exiting?
>
> "Lars-Ã…ke Aspelin" wrote:
>
>> On Fri, 2 Jan 2009 09:40:01 -0800, Nikki
>> <(E-Mail Removed)> 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
>>


 
Reply With Quote
 
Nikki
Guest
Posts: n/a
 
      2nd Jan 2009
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_ActualDataFile.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
> <(E-Mail Removed)> 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
> >> <(E-Mail Removed)> 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
> >>

>
>

 
Reply With Quote
 
PCLIVE
Guest
Posts: n/a
 
      2nd Jan 2009
Try using the word "Stop" (no quotes) in your code wherever you want it to
stop. That's what I do for testing purposes. Of course you would have to
manually continue.

Regards,
Paul

--

"Nikki" <(E-Mail Removed)> wrote in message
news:A23C15E9-B518-49DC-8E02-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Lars-Åke Aspelin
Guest
Posts: n/a
 
      2nd Jan 2009
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
<(E-Mail Removed)> 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_ActualDataFile.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
>> <(E-Mail Removed)> 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
>> >> <(E-Mail Removed)> 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
>> >>

>>
>>


 
Reply With Quote
 
Nikki
Guest
Posts: n/a
 
      2nd Jan 2009
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
> <(E-Mail Removed)> 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_ActualDataFile.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
> >> <(E-Mail Removed)> 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
> >> >> <(E-Mail Removed)> 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
> >> >>
> >>
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
code to stop all running macro's Imda14u Microsoft Excel Programming 1 8th Feb 2009 08:37 AM
Re: code to stop all running macro's Gord Dibben Microsoft Excel Programming 0 6th Feb 2009 09:22 PM
Can I use code/macro to change code/macro in an existing file? =?Utf-8?B?U2NvdHQgQmVkb3dz?= Microsoft Excel Programming 2 14th Feb 2007 05:50 AM
How to stop macro from code =?Utf-8?B?TGVlIEh1bnRlcg==?= Microsoft Access VBA Modules 15 11th Jul 2005 11:58 AM
Using code to stop a macro. Wrightr Microsoft Excel Programming 1 2nd Sep 2004 11:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:25 AM.