ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Pause Macro 2 (https://www.excelbanter.com/excel-discussion-misc-queries/94084-pause-macro-2-a.html)

Ollie

Pause Macro 2
 
have another pause macro problem.

I have created a macro
Dim myStr As String
myStr = InputBox(Prompt:="Please enter your name")
Range("a3").Select
ActiveCell.FormulaR1C1 = myStr
MsgBox " You entered:" &myStr
"other code that does more

The input box has 2 options OK and Cancel.

If I click on cancel it still continues with the "other code that does more"
instead of quiting the macro.

Would appreciate any help.

Thanks

Ken Johnson

Pause Macro 2
 

Ollie wrote:
have another pause macro problem.

I have created a macro
Dim myStr As String
myStr = InputBox(Prompt:="Please enter your name")
Range("a3").Select
ActiveCell.FormulaR1C1 = myStr
MsgBox " You entered:" &myStr
"other code that does more

The input box has 2 options OK and Cancel.

If I click on cancel it still continues with the "other code that does more"
instead of quiting the macro.

Would appreciate any help.

Thanks


Hi Ollie,

If you need to exit the macro when the user clicks cancel you will need
something like

If myStr = "" Then
Exit Sub
End If

Ken Johnson


Ollie

Pause Macro 2
 
Thanks again Ken.
This was an addition to yesterdays question.
Its so good to get this help.

Thaks a lot
Regards
Ollie

"Ken Johnson" wrote:


Ollie wrote:
have another pause macro problem.

I have created a macro
Dim myStr As String
myStr = InputBox(Prompt:="Please enter your name")
Range("a3").Select
ActiveCell.FormulaR1C1 = myStr
MsgBox " You entered:" &myStr
"other code that does more

The input box has 2 options OK and Cancel.

If I click on cancel it still continues with the "other code that does more"
instead of quiting the macro.

Would appreciate any help.

Thanks


Hi Ollie,

If you need to exit the macro when the user clicks cancel you will need
something like

If myStr = "" Then
Exit Sub
End If

Ken Johnson



Ken Johnson

Pause Macro 2
 
You're welcome Ollie, thanks for the feedback.

Ken Johnson



All times are GMT +1. The time now is 09:14 AM.

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