Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Delete all data on a worksheet

Hi all,
I want to delete all dat in the sheet1 when I close the workbook,
but not understand to write VBA code for excel.Is it possible ?
How to write it?

Many thank's.


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Delete all data on a worksheet

Hi,

Are you absolutely sure you want to delete everyting? Warning this will
delete everything in Sheet1 and I mean everything so use it with caution and
try it on a backup wotkbook first. Alt + F11 to open VB editor. Double click
'This workbook' and paste the code in.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Sheet1").UsedRange.ClearContents
End Sub

Mike

"shiro" wrote:

Hi all,
I want to delete all dat in the sheet1 when I close the workbook,
but not understand to write VBA code for excel.Is it possible ?
How to write it?

Many thank's.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Delete all data on a worksheet

Right-click on the Excel logo left of "File" on the main menu.

Select "View Code"

Paste this into that module.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Sheet1").Cells.ClearContents
.Save
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 21 Jan 2008 18:34:51 +0700, "shiro" wrote:

Hi all,
I want to delete all dat in the sheet1 when I close the workbook,
but not understand to write VBA code for excel.Is it possible ?
How to write it?

Many thank's.


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Delete all data on a worksheet

"logo" should have been "icon"


Gord

On Mon, 21 Jan 2008 10:48:31 -0800, Gord Dibben <gorddibbATshawDOTca wrote:

Right-click on the Excel logo left of "File" on the main menu.

Select "View Code"

Paste this into that module.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Sheet1").Cells.ClearContents
.Save
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 21 Jan 2008 18:34:51 +0700, "shiro" wrote:

Hi all,
I want to delete all dat in the sheet1 when I close the workbook,
but not understand to write VBA code for excel.Is it possible ?
How to write it?

Many thank's.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 9
Default Delete all data on a worksheet

Many thank's Sirs.
Workgreat.


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
"logo" should have been "icon"


Gord

On Mon, 21 Jan 2008 10:48:31 -0800, Gord Dibben <gorddibbATshawDOTca

wrote:

Right-click on the Excel logo left of "File" on the main menu.

Select "View Code"

Paste this into that module.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ThisWorkbook
.Worksheets("Sheet1").Cells.ClearContents
.Save
End With
End Sub


Gord Dibben MS Excel MVP

On Mon, 21 Jan 2008 18:34:51 +0700, "shiro" wrote:

Hi all,
I want to delete all dat in the sheet1 when I close the workbook,
but not understand to write VBA code for excel.Is it possible ?
How to write it?

Many thank's.






Reply
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
How do I delete data in worksheet, but not the associated formula cganno Excel Worksheet Functions 7 December 18th 08 01:32 AM
delete a worksheet april Excel Discussion (Misc queries) 2 March 30th 07 02:48 PM
How to delete a duplicate Excel worksheet within that worksheet? jozawun Excel Discussion (Misc queries) 6 September 19th 06 02:20 PM
How do you delete a worksheet? Don J Excel Discussion (Misc queries) 5 January 3rd 06 07:11 PM
how do I delete data from a worksheet without deleting the formul. Jack Excel Discussion (Misc queries) 1 February 17th 05 01:25 AM


All times are GMT +1. The time now is 12:32 PM.

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"