ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MsgBox Help (https://www.excelbanter.com/excel-programming/354284-msgbox-help.html)

Zach H

MsgBox Help
 

How can I program a MsgBox to pop up every time the program is opened?
want 2 to have 2 buttons, "yes" and "no". Yes lets you access th
spreadsheet, clicking no will not let you access the sheet. Thanks fo
your help!

Zac

--
Zach
-----------------------------------------------------------------------
Zach H's Profile: http://www.excelforum.com/member.php...fo&userid=3188
View this thread: http://www.excelforum.com/showthread.php?threadid=51616


gti_jobert[_37_]

MsgBox Help
 

Code
-------------------
Private Sub Workbook_Open()
msg = MsgBox("Access the Spreadsheet?", vbYesNo)
If msg = vbYes Then
Sheets("Sheet1").Activate
else
' closes the active workbook without saving any changes
ActiveWorkbook.Close False
end if
End Sub

-------------------

--
gti_jober
-----------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=51616


Bob Phillips[_6_]

MsgBox Help
 
Private Sub Workbook_Open()
If MsgBox("Yes or No ", vbYesNo) = vbYes Then
'do something
End If

End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Zach H" wrote in
message ...

How can I program a MsgBox to pop up every time the program is opened? I
want 2 to have 2 buttons, "yes" and "no". Yes lets you access the
spreadsheet, clicking no will not let you access the sheet. Thanks for
your help!

Zach


--
Zach H
------------------------------------------------------------------------
Zach H's Profile:

http://www.excelforum.com/member.php...o&userid=31888
View this thread: http://www.excelforum.com/showthread...hreadid=516160




Zach H[_2_]

MsgBox Help
 

Worked like a charm! Thanks!!


--
Zach H
------------------------------------------------------------------------
Zach H's Profile: http://www.excelforum.com/member.php...o&userid=31888
View this thread: http://www.excelforum.com/showthread...hreadid=516160



All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com