Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default before close event with condition

I'm a bit familiar with workbook event Workbook_BeforeClose.

I only want to run a msgBox if cell G2 has a certain value
(unbalanced) when the workbook is closed.

How can I do this?

Cheers,

Harold
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default before close event with condition

I'm a bit familiar with workbook event Workbook_BeforeClose.

The only code you'd need is this line in the Workbook_BeforeClose:
if range("g2").value = "unbalanced" then msgbox("This analysis does
not balance.")

Please try that, and let us know if you require anything else.

Dave O
Eschew Obfuscation
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default before close event with condition

On Nov 21, 9:59 am, Dave O wrote:
I'm a bit familiar with workbook event Workbook_BeforeClose.


The only code you'd need is this line in the Workbook_BeforeClose:
if range("g2").value = "unbalanced" then msgbox("This analysis does
not balance.")

Please try that, and let us know if you require anything else.

Dave O
Eschew Obfuscation


This works ok. Thanks!

Is there also a way to create the msgbox with a cancel option to be
able to go back and change the sheet.

Cheers,

Harold
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default before close event with condition

No, once you click the X or click File Close the file is going to
close. You might set up another event to warn the user, such as On
Save, or set the file so that cell A1 of every tab is painted red
until the analysis is balanced.
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default before close event with condition

Dave

Incorrect.

You can stop the closing of workbook.

See other posts in this thread.


Gord Dibben MS Excel MVP

On Tue, 20 Nov 2007 17:53:49 -0800 (PST), Dave O wrote:

No, once you click the X or click File Close the file is going to
close. You might set up another event to warn the user, such as On
Save, or set the file so that cell A1 of every tab is painted red
until the analysis is balanced.


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
lookup with multiple condition, but one condition to satisfy is en Eddy Stan Excel Worksheet Functions 2 October 27th 07 02:06 PM
why do all excel worksheets/workbooks close when I close one? Penny Excel Discussion (Misc queries) 1 November 29th 06 03:49 AM
event macro on a condition TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 December 19th 05 07:15 AM
Excel shoud not close all active books when clicking close button technomike Excel Discussion (Misc queries) 0 June 10th 05 05:35 PM
excel - Windows close button (x) should only close active workboo. CoffeeAdict Setting up and Configuration of Excel 3 February 8th 05 04:30 AM


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