Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default allow user to stop macro with yes no question

I would like to "lock" a page using a macro/button that says "Submit and
Lock", but I would like to give to display a message first that says "You
will not be able to make any more changes to this page. Are you sure you
want to proceed?" Then I would like for the user to be able to pick "Yes" or
"No" and suspend the macro if the user says "No."

How would I do this using code in an Excel macro?

Thanks in advance for your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default allow user to stop macro with yes no question

If InputBox(......) = "No" then
Exit Sub
End If

--
Best wishes,

Jim


"VMcD" wrote:

I would like to "lock" a page using a macro/button that says "Submit and
Lock", but I would like to give to display a message first that says "You
will not be able to make any more changes to this page. Are you sure you
want to proceed?" Then I would like for the user to be able to pick "Yes" or
"No" and suspend the macro if the user says "No."

How would I do this using code in an Excel macro?

Thanks in advance for your help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default allow user to stop macro with yes no question

here is the Yes/No code...

if msgbox("You will not be able to make any " & _
"more changes to this page. Are you " & _
"sure you want to proceed?", VbYesNo) = VbNo then
exit sub
end if
--
HTH...

Jim Thomlinson


"VMcD" wrote:

I would like to "lock" a page using a macro/button that says "Submit and
Lock", but I would like to give to display a message first that says "You
will not be able to make any more changes to this page. Are you sure you
want to proceed?" Then I would like for the user to be able to pick "Yes" or
"No" and suspend the macro if the user says "No."

How would I do this using code in an Excel macro?

Thanks in advance for your help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default allow user to stop macro with yes no question


Try pointing your macro button at these!
Regards,
Simon.

sub lockcells()
if msgbox(\"you will not be able to make any more changes to this page
are you sure you want to proceed?\", vbyesno, \"confirm decision\")
vbno then
exit sub
cells.select
selection.locked = true
selection.formulahidden = false
range(\"a1\").select
activesheet.protect drawingobjects:=true, contents:=true
scenarios:=true
activesheet.enableselection = xlnoselection
end sub

sub unlockcells()
if msgbox(\"you are about to unlock cells. are you sure you want t
proceed?\", vbyesno, \"confirm decision\") = vbno then
exit sub
activesheet.unprotect
cells.select
selection.locked = false
selection.formulahidden = false
range(\"a1\").select
end su

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=57142

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default allow user to stop macro with yes no question

That's EXACTLY what I needed! Thanks so much for your quick reply.

"Simon Lloyd" wrote:


Try pointing your macro button at these!
Regards,
Simon.

sub lockcells()
if msgbox(\"you will not be able to make any more changes to this page.
are you sure you want to proceed?\", vbyesno, \"confirm decision\") =
vbno then
exit sub
cells.select
selection.locked = true
selection.formulahidden = false
range(\"a1\").select
activesheet.protect drawingobjects:=true, contents:=true,
scenarios:=true
activesheet.enableselection = xlnoselection
end sub

sub unlockcells()
if msgbox(\"you are about to unlock cells. are you sure you want to
proceed?\", vbyesno, \"confirm decision\") = vbno then
exit sub
activesheet.unprotect
cells.select
selection.locked = false
selection.formulahidden = false
range(\"a1\").select
end sub


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=571422




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default allow user to stop macro with yes no question

I would use a "yes no" msgbox to do this.
If MsgBox("You will not be able to make any more changes to this page."
_
& "Are you sure you want to proceed?", vbYesNo, "Locking
Workbook...") _
= vbYes Then
MsgBox "User clicked yes"
Else
MsgBox "User clicked no"
End If

Charles
VMcD wrote:
I would like to "lock" a page using a macro/button that says "Submit and
Lock", but I would like to give to display a message first that says "You
will not be able to make any more changes to this page. Are you sure you
want to proceed?" Then I would like for the user to be able to pick "Yes" or
"No" and suspend the macro if the user says "No."

How would I do this using code in an Excel macro?

Thanks in advance for your help!


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
First Time Macro User--Stop Recording Toolbar [email protected] Excel Discussion (Misc queries) 1 November 16th 07 10:44 PM
Macro using question to proceed or stop mohavv Excel Discussion (Misc queries) 3 October 11th 07 02:04 AM
Macro stop if file in use by other user? Bry Excel Discussion (Misc queries) 5 August 11th 06 04:27 PM
Using macro to stop user from emailing workbook scooppbear Excel Discussion (Misc queries) 1 May 17th 06 05:43 AM
How to stop the user from seeing what's going on Jeff Excel Programming 4 May 24th 05 04:01 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"