LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default VBA for Clearing data from the worksheet

Thank you every one for your help. I created a reset button and it works well.
Dori

"sebastienm" wrote:

Hi,
What about:
1. clear all entries when the book opens
2. clear all entries when a button is clicked.

Let's first create a Clear procewdure, say ClearAllEntires
- go in the vba editor: from excel press ALT+F11 or menu TollsMacrosVisual
Basic Editor. There add a new code module (menu Insert Module)
- in this new module enter and modify the following sub:
Public Sub ClearAllEntires()
'here code to clear whatever needs to be cleared.
'eg: clear sheet1 A2:C100
Thisworkbook.Worksheets("Sheet1").Range("A2:C100") .ClearContents
'other clearings on a row each
End Sub

Then, let's call the macro from a button
- Make the Forms toolbar is visible: menu ViewToolbarsForms
-from the Forms toolbar, drag a button on the sheet
- the 'Assign Macro' dialog should pop up right away, if not, right-click
the new button and choose 'Assign Macro' from the pop up menu.
Assign the macro by selecting 'ClearAllEntires' from the list.
Now when the button is clicked the ClearAllEntires macro is run ie clearing
entry ranges. Note: you can have multiple buttons calling the same
ClearAllEntires sub.

Now, let's call the macro when the book opens to clear any data saved with
the book:
- in the ThisWorkbook code module (from the Project Explorer window in the
vba editor, double-click it to open the module), use the Workbook_Open sub
Private Sub Workbook_Open()
ClearAllEntires
End Sub


--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"DORI" wrote:

Is it possible to press a cell on the worksheet to clear all entered data in
the entire worksheet?
I have a worksheet that users enter several data in different pages and then
print a report. The next user will have to clear all eneries and then enter
their own data before printing the next report. At this time, we close the
program and reopen it which is a bit of pain, just wondering if thee is a VBA
code to activate create a key (let call it "Reset all Forms" on the worksheet
to press and clear all data.
I appreciate any comments in advance.
Dori



 
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
Clearing Data Troy2006 Excel Discussion (Misc queries) 3 October 31st 08 10:01 PM
Clear a worksheet without clearing formulas? doodah Excel Discussion (Misc queries) 5 January 23rd 07 06:45 PM
Worksheet clearing Macros? Arlen Excel Discussion (Misc queries) 4 January 27th 05 04:04 PM
clearing VBA worksheet names Maynard Excel Programming 2 July 8th 04 07:45 PM
Clearing Dropdowns In A Worksheet Aechelon Excel Programming 2 October 24th 03 01:41 AM


All times are GMT +1. The time now is 10:37 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"