Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default vbyesno msgbox

Dear Forum members,

When opening a workbook I would like to use a vbYesNo MsgBox to prompt the
user to answer yes or no to a given question. Depending on whether they
answer yes/no I want another MsgBox to confirm their input. I have tried
using the following but to no avail, can anyone please help? Thanks, Matt

Private Sub Workbook_Open()
MsgBox ("Question")
If MsgBox = vbYes Then
MsgBox ("Reply if yes")
Else
MsgBox ("Reply if no")
End If

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default vbyesno msgbox

dim x as variant
x = msgbox("Question")

if x = vbyesno...



"matt3542" wrote:

Dear Forum members,

When opening a workbook I would like to use a vbYesNo MsgBox to prompt the
user to answer yes or no to a given question. Depending on whether they
answer yes/no I want another MsgBox to confirm their input. I have tried
using the following but to no avail, can anyone please help? Thanks, Matt

Private Sub Workbook_Open()
MsgBox ("Question")
If MsgBox = vbYes Then
MsgBox ("Reply if yes")
Else
MsgBox ("Reply if no")
End If

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default vbyesno msgbox

Thanks Sam, much appreciated

"Sam Wilson" wrote:

dim x as variant
x = msgbox("Question")

if x = vbyesno...



"matt3542" wrote:

Dear Forum members,

When opening a workbook I would like to use a vbYesNo MsgBox to prompt the
user to answer yes or no to a given question. Depending on whether they
answer yes/no I want another MsgBox to confirm their input. I have tried
using the following but to no avail, can anyone please help? Thanks, Matt

Private Sub Workbook_Open()
MsgBox ("Question")
If MsgBox = vbYes Then
MsgBox ("Reply if yes")
Else
MsgBox ("Reply if no")
End If

End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default vbyesno msgbox

Option Explicit
Private Sub Workbook_Open()
dim Resp as long

resp = MsgBox(prompt:="Question", buttons:=vbyesno)
if resp = vbyes then
MsgBox "Reply if yes"
Else
MsgBox "Reply if no"
End If

End Sub

matt3542 wrote:

Dear Forum members,

When opening a workbook I would like to use a vbYesNo MsgBox to prompt the
user to answer yes or no to a given question. Depending on whether they
answer yes/no I want another MsgBox to confirm their input. I have tried
using the following but to no avail, can anyone please help? Thanks, Matt

Private Sub Workbook_Open()
MsgBox ("Question")
If MsgBox = vbYes Then
MsgBox ("Reply if yes")
Else
MsgBox ("Reply if no")
End If

End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default vbyesno msgbox

Thanks again Dave, appreciated

"Dave Peterson" wrote:

Option Explicit
Private Sub Workbook_Open()
dim Resp as long

resp = MsgBox(prompt:="Question", buttons:=vbyesno)
if resp = vbyes then
MsgBox "Reply if yes"
Else
MsgBox "Reply if no"
End If

End Sub

matt3542 wrote:

Dear Forum members,

When opening a workbook I would like to use a vbYesNo MsgBox to prompt the
user to answer yes or no to a given question. Depending on whether they
answer yes/no I want another MsgBox to confirm their input. I have tried
using the following but to no avail, can anyone please help? Thanks, Matt

Private Sub Workbook_Open()
MsgBox ("Question")
If MsgBox = vbYes Then
MsgBox ("Reply if yes")
Else
MsgBox ("Reply if no")
End If

End Sub


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vbyesno msgbox

If you won't need the answer to the question any place else in your code,
you can process the MsgBox response directly in the If..Then statement and
eliminate a variable (that would normally be used to hold the answer)...

Private Sub Workbook_Open()
If MsgBox(prompt:="Question", Buttons:=vbYesNo) = vbYes Then
MsgBox "Yes button was pressed"
Else
MsgBox "No button was pressed"
End If
End Sub

Rick


"matt3542" wrote in message
...
Dear Forum members,

When opening a workbook I would like to use a vbYesNo MsgBox to prompt the
user to answer yes or no to a given question. Depending on whether they
answer yes/no I want another MsgBox to confirm their input. I have tried
using the following but to no avail, can anyone please help? Thanks, Matt

Private Sub Workbook_Open()
MsgBox ("Question")
If MsgBox = vbYes Then
MsgBox ("Reply if yes")
Else
MsgBox ("Reply if no")
End If

End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default vbyesno msgbox

Hi Rick, Thankyou for taking the time to explain that, I did eventually try
that method and it worked.

Best regards
Matt

"Rick Rothstein (MVP - VB)" wrote:

If you won't need the answer to the question any place else in your code,
you can process the MsgBox response directly in the If..Then statement and
eliminate a variable (that would normally be used to hold the answer)...

Private Sub Workbook_Open()
If MsgBox(prompt:="Question", Buttons:=vbYesNo) = vbYes Then
MsgBox "Yes button was pressed"
Else
MsgBox "No button was pressed"
End If
End Sub

Rick


"matt3542" wrote in message
...
Dear Forum members,

When opening a workbook I would like to use a vbYesNo MsgBox to prompt the
user to answer yes or no to a given question. Depending on whether they
answer yes/no I want another MsgBox to confirm their input. I have tried
using the following but to no avail, can anyone please help? Thanks, Matt

Private Sub Workbook_Open()
MsgBox ("Question")
If MsgBox = vbYes Then
MsgBox ("Reply if yes")
Else
MsgBox ("Reply if no")
End If

End Sub




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
msgbox text vbyesno Curt Excel Programming 4 July 18th 07 04:20 PM
VbYesNo MsgBox won't respond to "No" Peter Rooney Excel Programming 4 December 22nd 05 04:01 PM
VBYesNo MsgBox - Computer always says "Yes" Peter Rooney Excel Discussion (Misc queries) 4 December 22nd 05 02:42 PM
VbYesNo Msg Box mjack003 Excel Discussion (Misc queries) 1 September 22nd 05 03:09 AM
vbYesNo mike allen Excel Programming 1 January 4th 04 03:59 PM


All times are GMT +1. The time now is 06:11 AM.

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"