Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Help accessing msgbox prompt via function

Hi,

In my ProSheets macro I wish to call myMsgbox function and return the
response back to my Prosheets macro so it does an action if = Yes or another
action if = no.

I'm almost there but can't crack the last part.

Bruce

Sub ProSheets()
myMSG = "Do you want to protect worksheets?"
myMsgbox (myMSG)

'If Yes then do this
'Else if No then do that
End Sub

Function myMsgbox(myMessage As String)
msg = myMessage
Style = vbYesNo + vbCritical + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
myMsgbox = "Yes"
Else
myMsgbox = "No"
End
End If
End Function
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Help accessing msgbox prompt via function

Do you mean....

Sub ProSheets()
Dim myMsG As String
myMsG = "Do you want to protect worksheets?"
If myMsgbox(myMsG) = "Yes" Then
'do something
Else
'do something
End If
End Sub

Function myMsgbox(myMessage As String) As Variant
myMsgbox = "No"
msg = myMessage
Style = vbYesNo + vbCritical + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then myMsgbox = "Yes"
End Function

--
If this post helps click Yes
---------------
Jacob Skaria


"Bruce" wrote:

Hi,

In my ProSheets macro I wish to call myMsgbox function and return the
response back to my Prosheets macro so it does an action if = Yes or another
action if = no.

I'm almost there but can't crack the last part.

Bruce

Sub ProSheets()
myMSG = "Do you want to protect worksheets?"
myMsgbox (myMSG)

'If Yes then do this
'Else if No then do that
End Sub

Function myMsgbox(myMessage As String)
msg = myMessage
Style = vbYesNo + vbCritical + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
myMsgbox = "Yes"
Else
myMsgbox = "No"
End
End If
End Function

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Help accessing msgbox prompt via function

aha - yes solves my problem. Thanks

"Jacob Skaria" wrote:

Do you mean....

Sub ProSheets()
Dim myMsG As String
myMsG = "Do you want to protect worksheets?"
If myMsgbox(myMsG) = "Yes" Then
'do something
Else
'do something
End If
End Sub

Function myMsgbox(myMessage As String) As Variant
myMsgbox = "No"
msg = myMessage
Style = vbYesNo + vbCritical + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then myMsgbox = "Yes"
End Function

--
If this post helps click Yes
---------------
Jacob Skaria


"Bruce" wrote:

Hi,

In my ProSheets macro I wish to call myMsgbox function and return the
response back to my Prosheets macro so it does an action if = Yes or another
action if = no.

I'm almost there but can't crack the last part.

Bruce

Sub ProSheets()
myMSG = "Do you want to protect worksheets?"
myMsgbox (myMSG)

'If Yes then do this
'Else if No then do that
End Sub

Function myMsgbox(myMessage As String)
msg = myMessage
Style = vbYesNo + vbCritical + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
myMsgbox = "Yes"
Else
myMsgbox = "No"
End
End If
End Function

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
HOW TO PROMPT MSGBOX JUST ONCE K[_2_] Excel Programming 6 June 15th 08 09:17 AM
VB - ignore a msgbox prompt Kevin Excel Discussion (Misc queries) 3 January 10th 08 11:47 AM
Entering variables on Msgbox prompt renegan[_6_] Excel Programming 3 January 4th 06 06:54 PM
Msgbox prompt and tabbing Neal Zimm Excel Programming 2 May 26th 05 01:52 PM
msgbox prompt when user selects data from combo box Tom Ogilvy Excel Programming 5 July 11th 03 09:24 PM


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