Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default Macro using question to proceed or stop

Hi,

I want to add a question to my macro if it is ok to run it or not (Are
you sure? Y/N).
So if you click yes it will proceed and if you click no it will stop.

I can't find out how to do this. Found Userform but I don't know how
to use it in a macro.

Any help pm this is welcome.

Cheers

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,101
Default Macro using question to proceed or stop

Try this
Sub yesOrNo()
If MsgBox("Run macro? Yes or No", vbYesNoCancel + vbQuestion) < vbYes Then
MsgBox "NO Dont Run Macro"
Else
MsgBox "Run Macro"
End If
End Sub

"mohavv" wrote:

Hi,

I want to add a question to my macro if it is ok to run it or not (Are
you sure? Y/N).
So if you click yes it will proceed and if you click no it will stop.

I can't find out how to do this. Found Userform but I don't know how
to use it in a macro.

Any help pm this is welcome.

Cheers


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Macro using question to proceed or stop

Don't need a user form, a simple msgbox will do.

Sub foo()

Style = vbYesNo
msg = "are you sure you want to run macro?"
Response = MsgBox(msg, Style)
If Response = vbYes Then
If Response = vbNo Then Exit Sub

your code goes here

End If
End Sub


Gord Dibben MS Excel MVP

On Wed, 10 Oct 2007 17:35:21 -0700, mohavv wrote:

Hi,

I want to add a question to my macro if it is ok to run it or not (Are
you sure? Y/N).
So if you click yes it will proceed and if you click no it will stop.

I can't find out how to do this. Found Userform but I don't know how
to use it in a macro.

Any help pm this is welcome.

Cheers


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default Macro using question to proceed or stop

On Oct 11, 1:52 pm, Mike wrote:
Try this
Sub yesOrNo()
If MsgBox("Run macro? Yes or No", vbYesNoCancel + vbQuestion) < vbYes Then
MsgBox "NO Dont Run Macro"
Else
MsgBox "Run Macro"
End If
End Sub



"mohavv" wrote:
Hi,


I want to add a question to my macro if it is ok to run it or not (Are
you sure? Y/N).
So if you click yes it will proceed and if you click no it will stop.


I can't find out how to do this. Found Userform but I don't know how
to use it in a macro.


Any help pm this is welcome.


Cheers- Hide quoted text -


- Show quoted text -


Thanks!
Works just fine.

If life was always this simple....

Cheers,

Harold

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
Macro - Stop Recording Phil vK Excel Discussion (Misc queries) 4 May 23rd 07 07:03 PM
How to proceed with consolidation Bob Excel Discussion (Misc queries) 2 March 16th 07 05:51 PM
not sure how to proceed inoexcel Excel Worksheet Functions 4 April 3rd 06 12:34 AM
Macro to stop at a certain tab and does not go to the next one. [email protected] Excel Worksheet Functions 3 March 16th 06 01:11 AM
Is there a way I can enter a letter to proceed text a column of ce Gordon Excel Discussion (Misc queries) 3 December 13th 04 07:13 PM


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

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

About Us

"It's about Microsoft Excel"