Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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.



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
Continue Quote Kev Setting up and Configuration of Excel 1 August 8th 09 04:19 PM
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work gpmichal Setting up and Configuration of Excel 1 May 12th 09 02:33 AM
How do I cancel the "Send this Sheet" option? John @ Spray Excel Discussion (Misc queries) 1 January 31st 07 07:35 PM
to continue down in the same row alex178 Excel Discussion (Misc queries) 2 July 8th 06 05:34 PM
Abort or continue Ed Ferrero[_4_] Excel Programming 0 August 5th 03 02:01 AM


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