Re: change cell on exit vba



Success will also be thwarted if in the shorter version the user presses 'NO'
to save changes.

Macro - Something:- that does what you tell it to do and not what you want
it to do. Anonymous.


"Tom Ogilvy" wrote:

Just to add,
Unless it is a single *** workbook, the results might be more satisfying
if the range is qualified with a specific *** name. Otherwise, the command
assumes the active*** and success clearing a specific range on a specific
*** in Thisworkbook (assuming that is the objective) might be thwarted by
the user.

--
Regards,
Tom Ogilvy


"Vasant Nanavati" wrote:

A little shorter:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Range("A1:B100").ClearContents 'alter range to suit
End Sub

_____________________________________________________________________


"Mike H" <MikeH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0E5277AD-042F-4F4C-8392-1A98922FE134@xxxxxxxxxxxxxxxx
Try this in the before_close workbook event:-

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Set myRange = Worksheets("Sheet1").Range("A1:B100") '< Alter to suit
With myRange
.Select
.Clear
End With
ActiveWorkbook.Save
End Sub

"Joost" wrote:

Hello,

Is it possible to clear cells when a workbook is closed with vba
automatically.
I can't figur it out who can help me

Thanks






.