Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Nick
 
Posts: n/a
Default How do I insert a 'clear all' button in excel?

I would like to insert a button into a quotation form that will clear data
from all unlocked cells ie name, address equipment and costings. The form
was created in Excel.
  #2   Report Post  
Paul B
 
Posts: n/a
Default

Nick, this will unlock the sheet, clear all the unlocked cells on a
worksheet, protect the sheet, is this what you want? you say form, but it
sounds like you are talking about unlocked cells in the worksheet

Sub Clear_Unlocked()
Dim Cel As Range
Const Password = "123" '**Change password here**
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=Password
For Each Cel In ActiveSheet.UsedRange.Cells
If Cel.Locked = False Then Cel.Formula = ""
Next
ActiveSheet.Protect Password:=Password
Application.ScreenUpdating = True
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Nick" wrote in message
...
I would like to insert a button into a quotation form that will clear data
from all unlocked cells ie name, address equipment and costings. The form
was created in Excel.



  #3   Report Post  
Nick
 
Posts: n/a
Default



"Paul B" wrote:

Nick, this will unlock the sheet, clear all the unlocked cells on a
worksheet, protect the sheet, is this what you want? you say form, but it
sounds like you are talking about unlocked cells in the worksheet

Sub Clear_Unlocked()
Dim Cel As Range
Const Password = "123" '**Change password here**
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=Password
For Each Cel In ActiveSheet.UsedRange.Cells
If Cel.Locked = False Then Cel.Formula = ""
Next
ActiveSheet.Protect Password:=Password
Application.ScreenUpdating = True
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Nick" wrote in message
...
I would like to insert a button into a quotation form that will clear data
from all unlocked cells ie name, address equipment and costings. The form
was created in Excel.



Hi Paul and thanks for your message. The form I have created is for quotations and used by 5 people, all parts of the form are locked off apart from the parts where they can fill in details like name, address and prices etc. What I would like to do is add a button that allows the form to be reset ie removing all data that the last operator has inserted into the form. Thanks for your help.


Nick
  #4   Report Post  
Paul B
 
Posts: n/a
Default

Nick,
"I would like to insert a button into a quotation form that will clear data
from all unlocked cells "

The code I posted will do that, if this is not what you want what cells do
you want to clear? A2:A10, C5, H10......, you may also want to try and save
the file as a template, then when you open it you will have a blank copy
each time.

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Nick" wrote in message
...


"Paul B" wrote:

Nick, this will unlock the sheet, clear all the unlocked cells on a
worksheet, protect the sheet, is this what you want? you say form, but

it
sounds like you are talking about unlocked cells in the worksheet

Sub Clear_Unlocked()
Dim Cel As Range
Const Password = "123" '**Change password here**
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:=Password
For Each Cel In ActiveSheet.UsedRange.Cells
If Cel.Locked = False Then Cel.Formula = ""
Next
ActiveSheet.Protect Password:=Password
Application.ScreenUpdating = True
End Sub

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Nick" wrote in message
...
I would like to insert a button into a quotation form that will clear

data
from all unlocked cells ie name, address equipment and costings. The

form
was created in Excel.



Hi Paul and thanks for your message. The form I have created is for

quotations and used by 5 people, all parts of the form are locked off apart
from the parts where they can fill in details like name, address and prices
etc. What I would like to do is add a button that allows the form to be
reset ie removing all data that the last operator has inserted into the
form. Thanks for your help.

Nick



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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
insert a JPEG into EXCEL 2002 mckee Excel Discussion (Misc queries) 3 March 11th 05 05:03 PM
Challenging Charting C TO Charts and Charting in Excel 0 January 17th 05 06:57 PM
command button in excel will move when print. [email protected] Excel Discussion (Misc queries) 1 December 29th 04 03:53 PM
How do I setup a spin button in excel Andy K Excel Discussion (Misc queries) 1 November 26th 04 09:08 PM


All times are GMT +1. The time now is 08:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"