ExcelBanter

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

Ollie

Pause Excel Macro
 
I have followed a discussion group suggestion and created a macro as follows:
dim myStr as string
"your code that does something'
mystr = inputbox (Prompy:= "Please type something")
msgbox "Hey, you typed: " & mystr
"your code that does more'

This works well thanks to Dave Peterson but when I run the macro it gives 2
option Cancel and OK. I was wondering if it can be created to only give the
OK option so that something must be entered to continue.

Thanks

Ken Johnson

Pause Excel Macro
 
Ollie wrote:
I have followed a discussion group suggestion and created a macro as follows:
dim myStr as string
"your code that does something'
mystr = inputbox (Prompy:= "Please type something")
msgbox "Hey, you typed: " & mystr
"your code that does more'

This works well thanks to Dave Peterson but when I run the macro it gives 2
option Cancel and OK. I was wondering if it can be created to only give the
OK option so that something must be entered to continue.

Thanks


Hi Ollie,

Here's one way...

Public Sub MustEnter()
Dim mystring As String
Do While mystring = ""
mystring = InputBox("Please type something")
If mystring = "" Then MsgBox _
"You're not getting off that lightly buster!"
Loop
MsgBox "You typed " & mystring
End Sub
According to the help files there is no option for changing the
inputbox buttons.

Ken Johnson


Ollie

Pause Excel Macro
 
Thank you Ken

This works very well for me.
Very much appreciate you help
Regards
Ollie

"Ken Johnson" wrote:

Ollie wrote:
I have followed a discussion group suggestion and created a macro as follows:
dim myStr as string
"your code that does something'
mystr = inputbox (Prompy:= "Please type something")
msgbox "Hey, you typed: " & mystr
"your code that does more'

This works well thanks to Dave Peterson but when I run the macro it gives 2
option Cancel and OK. I was wondering if it can be created to only give the
OK option so that something must be entered to continue.

Thanks


Hi Ollie,

Here's one way...

Public Sub MustEnter()
Dim mystring As String
Do While mystring = ""
mystring = InputBox("Please type something")
If mystring = "" Then MsgBox _
"You're not getting off that lightly buster!"
Loop
MsgBox "You typed " & mystring
End Sub
According to the help files there is no option for changing the
inputbox buttons.

Ken Johnson



Ken Johnson

Pause Excel Macro
 

You're welcome Ollie, thanks for the feedback.

Ken Johnson



All times are GMT +1. The time now is 02:50 PM.

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