LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Clearing cells in a range upon exitting Excel

Hi,

Before_Close is a workbook event. In VB editor double click 'ThisWorkbook'
and paste the code in there. Note that here you must qualify the range with a
sheet name.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").Range("b18:l40").ClearContents
End Sub

Mike

"E" wrote:

Like the title says, I am working on a project in Excel that requires that
the data entered in a range be cleared. I tried the following code in the
deactivate event of the worksheet:

Private Sub Worksheet_Deactivate()
Range("b18:l40").ClearContents
End Sub

This works fine if I switching worksheets but I would like the clear to
occur when closing Excel. I did not see a "OnClose" type event where I could
put the code for clearing the selection.

Thanks in advance.

 
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
Deleting/Clearing duplicate range of cells Steve Excel Worksheet Functions 0 April 28th 10 03:59 PM
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
Clearing cells in a range upon exitting Excel Don Guillett Excel Programming 0 January 14th 09 07:24 PM
Clearing the Contents of a range of cells David A. Excel Programming 2 November 8th 07 05:59 PM
need some help clearing a range Gary Keramidas Excel Programming 4 August 18th 06 03:07 AM


All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"