Solved

Delete data on close

Posted on 2013-10-28
4
255 Views
Last Modified: 2013-10-28
How would I go about deleting data from an entire section upon closing the workbook.  

I would like to delete the range B2:J1000 at the close.

Any ideas?  thanks,
0
Comment
Question by:BostonBob
4 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 39607567
Please see if the attached works for you.
Testworkbook.xlsm
0
 

Author Comment

by:BostonBob
ID: 39607737
I was just about to say the same thing.  thanks.
0
 
LVL 81

Accepted Solution

by:
byundt earned 500 total points
ID: 39607739
The following macro (which must be installed in the ThisWorkbook code pane) will clear cells B2:J1000 from the first worksheet in the workbook, then save the file. It is triggered by the user trying to close the workbook.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets(1).Range("B2:J1000").ClearContents
ThisWorkbook.Save
End Sub

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question