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

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default VBA for Clearing data from the worksheet


"DORI" skrev i meddelandet
...
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


No, but I can think of some altrenatives
1) Let each user work on a copy of the original sheet.
2) If you know in advance what cells are used, you could make a macro that
cleans the sheet. You could record it and then edit the generated code to
make sure it clears all cells where data is entered.

/Fredrik.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA for Clearing data from the worksheet

Dori,

How about dragging a button off of the forms toolbar, and assigning a clear
macro to that?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"DORI" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default VBA for Clearing data from the worksheet

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default VBA for Clearing data from the worksheet

Dori

CTRL + a to select all cells on a worksheet.

EditClearContents to blank the cells.

To have the same command on a button.

Sub gone()
ActiveSheet.Cells.ClearContents
End Sub

Insert a button from the Forms Toolbar and assign the macro to that button.


Gord Dibben Excel MVP

On Wed, 30 Nov 2005 12:30:06 -0800, "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




  #6   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

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
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 04:20 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"