#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 89
Default Yes or no msg box

please help how can I assign macro in msgbox that if he click yes to go
sheet1 if he click no to stay on active sheet

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Yes or no msg box


If MsgBox("Goto Sheet1?",vbYesNo) = vbYes Then
Worksheets("Sheet1").Activate
End If

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"George A. Jululian" wrote in
message ...
please help how can I assign macro in msgbox that if he click yes to go
sheet1 if he click no to stay on active sheet

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Yes or no msg box

Option Explicit
sub Test()
dim resp as long

resp = msgbox(Prompt:="Go to Sheet1", buttons:=vbyesno)

if resp = vbyes then
worksheets("sheet1").select
end if
end sub



George A. Jululian wrote:

please help how can I assign macro in msgbox that if he click yes to go
sheet1 if he click no to stay on active sheet

Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 903
Default Yes or no msg box

worksheets(1) for first sheet
worksheets("sheet1") for named sheet
vbYesCancel might be used instead

Sub stay_OR_Sheet1()
MsgBox "Do you want to go sheet1", vbYesNo
On Error Resume Next
If vbYes Then Worksheets("sheet4").Activate
If Err.Number = 9 Then
MsgBox "Sorry but sheet4 no longer exits, so staying here anyway"
End
On Error GoTo 0
Rem rest of code
End Sub

For more information see HELP while within the VBA editor, and perhaps
http://www.mvps.org/dmcritchie/excel/inputbox.htm

--
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"George A. Jululian" wrote in message
...
please help how can I assign macro in msgbox that if he click yes to go
sheet1 if he click no to stay on active sheet

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 903
Default Yes or no msg box

Sorry about not changing code after testing
they should all show sheet1

If vbYes Then Worksheets("sheet1").Activate


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



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