Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 590
Default VBA Code ... Run-skip-run ... Code

Excel2003 ... I have Macros (note: I record only, then cut/paste) where I
have a MsgBox (YES/NO) where ... YES = continue running Macro ... NO = Exit
Sub ... These work fine ...

However, in addition to above ... I would like simplified Code that will
allow for ... Run/Skip/Run ... in addition to Run/Exit (above).

ie: I have 1000 lines of Code & I want a YES/NO option to run lines 400-600
or skip these lines ... Run Macro =

Run lines 1-399 ...
YES/NO Msg Box ...
YES = Continue running lines 400-1000
NO = Skip lines 400-600 ... resume running @ line 601-1000

Note: I need capability to edit the YES/NO & what is Run/Skipped so I can
use these edited lines of Code in other Macros where I wish to ...
Run/Skip/Run ...

Gord Dibben has provided a lot of guidance (separate post & my sincere
Thanks) ... However, based on his latest response I am now posting this
question to the Programmers ... Thanks ... Kha
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default VBA Code ... Run-skip-run ... Code

The structure would look something like this:

Run lines 1-399
If YES/NO Msg Box = YES Then
lines 400-1000
End If
Run lines 601-1000

If you have a 1000 line macro you may want to invest some time learning more
about VBA than just recording. The recorded code can get the job done, but
almost never in the most efficient or flexible way.

"Ken" wrote in message
...
Excel2003 ... I have Macros (note: I record only, then cut/paste) where I
have a MsgBox (YES/NO) where ... YES = continue running Macro ... NO =
Exit
Sub ... These work fine ...

However, in addition to above ... I would like simplified Code that will
allow for ... Run/Skip/Run ... in addition to Run/Exit (above).

ie: I have 1000 lines of Code & I want a YES/NO option to run lines
400-600
or skip these lines ... Run Macro =

Run lines 1-399 ...
YES/NO Msg Box ...
YES = Continue running lines 400-1000
NO = Skip lines 400-600 ... resume running @ line 601-1000

Note: I need capability to edit the YES/NO & what is Run/Skipped so I can
use these edited lines of Code in other Macros where I wish to ...
Run/Skip/Run ...

Gord Dibben has provided a lot of guidance (separate post & my sincere
Thanks) ... However, based on his latest response I am now posting this
question to the Programmers ... Thanks ... Kha



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default VBA Code ... Run-skip-run ... Code

Rather than testing for a=7 (or vbNo), test for a =vbYes. If a does =
vbYes, the code between the IF and END IF statements will be executed,
otherwise they will be skipped and execution will pick-up after the End If.
Something like this (I replaced the 6/7 with vbYes/vbNo for programming
clarity).

a = MsgBox("Text" + Chr(13) + Chr(13) + "Text" + Chr(13) + Chr(13) + "Text",
vbYesNo, "ATTENTION!!!")

If a = vbYes Then
Execute lines 400-600
End If

Execute Lines 601-1000


"Ken" wrote in message
...
1000 lines is an over dramatization on my part ... My actual Code is less
than 100 lines ... The cut/paste MsgBox & Code instruction I presently
have
in my Recorded Macro for ... Continue/Exit ... is:

a = MsgBox("Text" + Chr(13) + Chr(13) + "Text" + Chr(13) + Chr(13) +
"Text",
vbYesNo, "ATTENTION!!!")
If a = 7 Then Exit Sub

However, rather than Exit the Sub at this point ... I want option to
continue running @ some later point in the Sub ...

What would explicit Code be to achieve this? ... Note, I need capability
to
edit for other Subs where I might want to implement a RUN-SKIP-RUN option
within the Sub.

Thanks ... Kha


"M. Authement" wrote:

The structure would look something like this:

Run lines 1-399
If YES/NO Msg Box = YES Then
lines 400-1000
End If
Run lines 601-1000

If you have a 1000 line macro you may want to invest some time learning
more
about VBA than just recording. The recorded code can get the job done,
but
almost never in the most efficient or flexible way.

"Ken" wrote in message
...
Excel2003 ... I have Macros (note: I record only, then cut/paste)
where I
have a MsgBox (YES/NO) where ... YES = continue running Macro ... NO =
Exit
Sub ... These work fine ...

However, in addition to above ... I would like simplified Code that
will
allow for ... Run/Skip/Run ... in addition to Run/Exit (above).

ie: I have 1000 lines of Code & I want a YES/NO option to run lines
400-600
or skip these lines ... Run Macro =

Run lines 1-399 ...
YES/NO Msg Box ...
YES = Continue running lines 400-1000
NO = Skip lines 400-600 ... resume running @ line 601-1000

Note: I need capability to edit the YES/NO & what is Run/Skipped so I
can
use these edited lines of Code in other Macros where I wish to ...
Run/Skip/Run ...

Gord Dibben has provided a lot of guidance (separate post & my sincere
Thanks) ... However, based on his latest response I am now posting this
question to the Programmers ... Thanks ... Kha






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros skip steps and/or stops in the middle of code [email protected] Excel Programming 5 November 9th 06 09:18 PM
How to have a Macro skip code if PivotTable/PivotField is not there [email protected] Excel Programming 0 January 29th 06 11:38 AM
skip some code davegb Excel Programming 5 December 1st 05 05:22 PM
skip code monika Excel Programming 1 February 26th 04 02:33 AM
Excel skip some lines of VBA code Alex[_7_] Excel Programming 1 August 28th 03 12:18 PM


All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"