Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default Before Close event

I'm adding a macro in the Workbook_BeforeClose module to check a specific
sheet in the workbook for data. If there is data, a msgbox is displayed with
a Yes, No, Cancel button.

If the user clicks, "yes", then it will clear the sheet and close the workbook

If the user clicks, "no" it will send the data to a database and close the
workbook

If the user clicks, "cancel", I want the close to stop so the user can
review the data.

I have tried the following code but the workbook still closes.

If MyAnswer = 2 Then End

Any suggestions on how to stop the close process would be greatly
appreciated. Thanks for the help.
--
JT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default Before Close event

On Apr 5, 10:06 am, JT wrote:
I'm adding a macro in the Workbook_BeforeClose module to check a specific
sheet in the workbook for data. If there is data, a msgbox is displayed with
a Yes, No, Cancel button.

If the user clicks, "yes", then it will clear the sheet and close the workbook

If the user clicks, "no" it will send the data to a database and close the
workbook

If the user clicks, "cancel", I want the close to stop so the user can
review the data.

I have tried the following code but the workbook still closes.

If MyAnswer = 2 Then End

Any suggestions on how to stop the close process would be greatly
appreciated. Thanks for the help.
--
JT


Private Sub Workbook_BeforeClose(Cancel As Boolean)

under your sub, if the vbanswer is cancel, then set Cancel = True

This should stop your workbook from closing...
Rob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Before Close event

Instead of this line

If MyAnswer = 2 Then End

Use this

If MyAnswer = 2 Then Cancel=True


--
Hope that helps.

Vergel Adriano


"JT" wrote:

I'm adding a macro in the Workbook_BeforeClose module to check a specific
sheet in the workbook for data. If there is data, a msgbox is displayed with
a Yes, No, Cancel button.

If the user clicks, "yes", then it will clear the sheet and close the workbook

If the user clicks, "no" it will send the data to a database and close the
workbook

If the user clicks, "cancel", I want the close to stop so the user can
review the data.

I have tried the following code but the workbook still closes.

If MyAnswer = 2 Then End

Any suggestions on how to stop the close process would be greatly
appreciated. Thanks for the help.
--
JT

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
open & close event Curt Excel Programming 2 March 5th 07 04:57 PM
Worksheet close event Baapi Excel Programming 4 May 9th 06 05:10 AM
EXCEL close event? bmm Excel Programming 1 November 9th 04 01:51 PM
Don't save before close event? Don Wiss Excel Programming 1 September 18th 04 01:51 AM
After Close Event? Don Wiss Excel Programming 2 November 19th 03 12:30 AM


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