ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GoTo from a form button to a macro (https://www.excelbanter.com/excel-programming/346586-goto-form-button-macro.html)

Spike

GoTo from a form button to a macro
 
I have a macro that calls a Form on an error. This form gives the user the
choice of Continueing or Exiting. If the Continue button is selected how do
i get the focus (after unloading the form) to return to a particular part of
the macro; as one would with a GoTo command in a macro. i want to return to
the calling macro but at a different place from where the form is called.

Any advices will be gratefully received.

many thanks
--
with kind regards

Spike

Tim Boswell

GoTo from a form button to a macro
 


"Spike" wrote:

I have a macro that calls a Form on an error. This form gives the user the
choice of Continueing or Exiting. If the Continue button is selected how do
i get the focus (after unloading the form) to return to a particular part of
the macro; as one would with a GoTo command in a macro. i want to return to
the calling macro but at a different place from where the form is called.

Any advices will be gratefully received.


Hi Spike,

The cleanest way to do this would be to have a seperate Sub for the macro at
the new entry point. For example, if you wanted to skip a chunk of code, you
would work along the lines below:

Old code:
DoSomeStuff
If error then displaycontinueform
DoSomeOtherStuff
DoEvenMoreStuff

New code:
Do some stuff
If error then displaycontinueform
If UserClicksContinue then RunFromThisPoint
DoSomeOtherStuff
RunFromThisPoint

Sub RunFromThisPoint
DoEvenMoreStuff
End Sub

I hope this helps

--
TimB




All times are GMT +1. The time now is 05:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com