ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   confirmation and close (https://www.excelbanter.com/excel-programming/303020-confirmation-close.html)

bigandyt[_2_]

confirmation and close
 
i was wondering if it is possible to insert vb code in a macro that wil
display to the user "are u sure u want to do this" or along thos
lines, if yes the rest of the macro is executed else the macro stops.


also i want to get rid of the 'X' at the top right of my form so th
user cannot close the form is this possible

any help would be appreciated

And

--
Message posted from http://www.ExcelForum.com


Fred[_18_]

confirmation and close
 
Andy,

try this:

Sub Sure()

If MsgBox("Are you sure you want to ****inue ?", vbYesNo, "Countinue ?") =
vbNo Then Exit Sub

'Go on with the code which has to be executed here
MsgBox ("You decided to continue")

End Sub




"bigandyt " schreef in bericht
...
i was wondering if it is possible to insert vb code in a macro that will
display to the user "are u sure u want to do this" or along those
lines, if yes the rest of the macro is executed else the macro stops.


also i want to get rid of the 'X' at the top right of my form so the
user cannot close the form is this possible

any help would be appreciated

Andy


---
Message posted from http://www.ExcelForum.com/




Harald Staff

confirmation and close
 
Hi Andy

Sub Dothings()
MsgBox "I work"
If MsgBox("Continue ?", vbYesNo + vbQuestion) = vbNo _
Then Exit Sub
MsgBox "Still working"
End Sub

As for the form X, is it userform. Will disabling it do ?
http://j-walk.com/ss/excel/tips/tip80.htm
If not it needs some quite heavy windows techniques, see FormFun at
http://www.bmsltd.ie/Excel/Default.htm

HTH. Best wishes Harald

"bigandyt " skrev i melding
...
i was wondering if it is possible to insert vb code in a macro that will
display to the user "are u sure u want to do this" or along those
lines, if yes the rest of the macro is executed else the macro stops.


also i want to get rid of the 'X' at the top right of my form so the
user cannot close the form is this possible

any help would be appreciated

Andy


---
Message posted from http://www.ExcelForum.com/




papou[_9_]

confirmation and close
 
Hi Andy
If MsgBox("Are you sure you want to do this?", vbYesNo + vbsuestion, "Please
confirm") = vbNo Then Exit Sub
MsgBox "not cancelled"
'do your stuff

To prevent closing your form add this into the form's code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode < 1 Then Cancel = 1
End Sub

HTH
Cordially
Pascal

"bigandyt " a écrit dans le
message de ...
i was wondering if it is possible to insert vb code in a macro that will
display to the user "are u sure u want to do this" or along those
lines, if yes the rest of the macro is executed else the macro stops.


also i want to get rid of the 'X' at the top right of my form so the
user cannot close the form is this possible

any help would be appreciated

Andy


---
Message posted from http://www.ExcelForum.com/




papou[_9_]

confirmation and close
 
Sorry please amend :
If MsgBox("Are you sure you want to do this?", vbYesNo + vbQuestion, "Please
confirm") = vbNo Then Exit Sub

Pascal

"papou" a écrit dans le message de
...
Hi Andy
If MsgBox("Are you sure you want to do this?", vbYesNo + vbsuestion,

"Please
confirm") = vbNo Then Exit Sub
MsgBox "not cancelled"
'do your stuff

To prevent closing your form add this into the form's code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode < 1 Then Cancel = 1
End Sub

HTH
Cordially
Pascal

"bigandyt " a écrit dans le
message de ...
i was wondering if it is possible to insert vb code in a macro that will
display to the user "are u sure u want to do this" or along those
lines, if yes the rest of the macro is executed else the macro stops.


also i want to get rid of the 'X' at the top right of my form so the
user cannot close the form is this possible

any help would be appreciated

Andy


---
Message posted from http://www.ExcelForum.com/







All times are GMT +1. The time now is 05:16 AM.

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