ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Option to continue or cancel (https://www.excelbanter.com/excel-programming/300583-option-continue-cancel.html)

Ken G[_2_]

Option to continue or cancel
 
I have a macro which deletes completed jobs from a spreadsheet. Since this action is not reversible I'd like an option box of some sort to appear when the macro is first invoked to say that the action is not reversible and then have a proceed or cancel option which would either execute the macro or end out of it

Thanks
Ken G.

Charles

Option to continue or cancel
 
KenG


Here is a bit of code you could use.

Sub msg_box()
Dim ans As String

ans = MsgBox("Attention you are about to delete are you sure you wan
to?", vbYesNo)
If ans = vbYes Then
'your code
ElseIf ans = vbNo Then
Exit Sub
End If
End Sub

Charle

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


mudraker[_254_]

Option to continue or cancel
 
Try

Select Case MsgBox("Please Confirm " _
& "You Wish To Permantley Delete This Record", _
vbYesNo + vbExclamation + vbDefaultButton2)
Case vbYes
Delete Record code here
End Selec

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


David Adamson[_3_]

Option to continue or cancel
 
Ken,

Adapt this. It is just a Msg box that then when "yes" is slected it closes
down any open workbook

----------------
Dim Msg, Style, Title, Response
Msg = "Wellcome to the proposed outline" & Chr(13) & _
"It is advised that you should close all other open workbooks to prevent
potential conflict with this model." & Chr(13) & _
"To close and save other spreadsheets press YES?" & Chr(13) & _
"To ignore this warning and keep existing workbooks open, press NO" '
Define message."

Style = vbYesNo + vbExclamation + vbDefaultButton2 ' Define buttons.
Title = "Selection" ' Define title.
'Display message.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.

For Each wkb In Workbooks
If Not wkb Is ThisWorkbook Then
wkb.Close savechanges:=True
End If
Next wkb
End If


"Ken G" wrote in message
...
I have a macro which deletes completed jobs from a spreadsheet. Since this

action is not reversible I'd like an option box of some sort to appear when
the macro is first invoked to say that the action is not reversible and then
have a proceed or cancel option which would either execute the macro or end
out of it.

Thanks,
Ken G.





All times are GMT +1. The time now is 12:00 AM.

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