Solved

Delete data on close

Posted on 2013-10-28
4
250 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
Comment Utility
Please see if the attached works for you.
Testworkbook.xlsm
0
 

Author Comment

by:BostonBob
Comment Utility
I was just about to say the same thing.  thanks.
0
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now