Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Yes or No Box then run macro

Hi

I have two macros,

I want to run a macro based on whether the user clicks yes to a
question or no to a question,

I do not know how to make this message popup on screen,

Can someone help?

Thanks

Andrea

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Yes or No Box then run macro

Hi,

I want to run a macro based on whether the user clicks yes to a
question or no to a question,

I do not know how to make this message popup on screen,


Like this:

Sub AskQuestion
If Msgbox("Turn Left?",vbyesNo+vbQuestion)=vbYes Then
TurnLeft
Else
TurnRight
End If
End Sub

Sub TurnLeft()
Msgbox "Going to the left!"
End Sub

Sub TurnRight()
Msgbox "Going to the right!"
End Sub

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Yes or No Box then run macro

One way is to paste this into a module and put a button on your worksheet to
call it:-

Sub answerme()
msg = "Answer YES or NO"
response = MsgBox(msg, vbYesNo)
If response = vbYes Then
MsgBox ("You clicked YES")
'Run the yes macro
Else
MsgBox ("You clicked NO")
'Run the no macro
End If
End Sub

Mike

" wrote:

Hi

I have two macros,

I want to run a macro based on whether the user clicks yes to a
question or no to a question,

I do not know how to make this message popup on screen,

Can someone help?

Thanks

Andrea


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Yes or No Box then run macro

Hi

Thanks for the response,

The first option was what I needed as the macro works with multiple
files. Only one problem so far,

When my macro is looping through the questions the window does not
refresh so the question windows appears behind the other one when it
has been clicked.....Where can I add a window refresh so the box
disappears when the question has been answered,

Many thanks,

Andrea

On May 15, 11:17 am, Mike H wrote:
One way is to paste this into a module and put a button on your worksheet to
call it:-

Sub answerme()
msg = "Answer YES or NO"
response = MsgBox(msg, vbYesNo)
If response = vbYes Then
MsgBox ("You clicked YES")
'Run the yes macro
Else
MsgBox ("You clicked NO")
'Run the no macro
End If
End Sub

Mike



" wrote:
Hi


I have two macros,


I want to run a macro based on whether the user clicks yes to a
question or no to a question,


I do not know how to make this message popup on screen,


Can someone help?


Thanks


Andrea- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Yes or No Box then run macro

Sub MyQuestion()
If MsgBox("Yes or No?", vbYesNo + vbQuestion) < vbYes Then
MsgBox "No Macro"
Else
MsgBox "Yes Macro"
End If
End Sub

" wrote:

Hi

I have two macros,

I want to run a macro based on whether the user clicks yes to a
question or no to a question,

I do not know how to make this message popup on screen,

Can someone help?

Thanks

Andrea




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Yes or No Box then run macro

Hi

This does not answer my previous question about the updating of the
questions to refresh the screen,

Can someone else help?

Andrea

On May 15, 11:58 am, Mike wrote:
Sub MyQuestion()
If MsgBox("Yes or No?", vbYesNo + vbQuestion) < vbYes Then
MsgBox "No Macro"
Else
MsgBox "Yes Macro"
End If
End Sub



" wrote:
Hi


I have two macros,


I want to run a macro based on whether the user clicks yes to a
question or no to a question,


I do not know how to make this message popup on screen,


Can someone help?


Thanks


Andrea- Hide quoted text -


- Show quoted text -



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 recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 08:30 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"