Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
HOW TO PROMPT MSGBOX JUST ONCE | Excel Programming | |||
VB - ignore a msgbox prompt | Excel Discussion (Misc queries) | |||
Entering variables on Msgbox prompt | Excel Programming | |||
Msgbox prompt and tabbing | Excel Programming | |||
msgbox prompt when user selects data from combo box | Excel Programming |