• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Delete data on close

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
BostonBob
Asked:
BostonBob
1 Solution
 
Peter KwanAnalyst ProgrammerCommented:
Please see if the attached works for you.
Testworkbook.xlsm
0
 
BostonBobAuthor Commented:
I was just about to say the same thing.  thanks.
0
 
byundtCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now