PC Review


Reply
Thread Tools Rate Thread

Data Validation and a Clear Button

 
 
mrhilder@gmail.com
Guest
Posts: n/a
 
      31st Dec 2007
Hi,

I'm not very knowledgeable on codes and all that intails. What I'm
trying to do with Microsoft Excel is create a spreadsheet using data
validation. I've gotten that part complete. Now what i'm trying to
do is add a "Clear" button so that the drop down data validation cells/
menus will remain intact but the clear button will turn the cells
blank so that the input user will be able to start over with the drop
down menus. Hope this makes sense. Thanks for any help.
 
Reply With Quote
 
 
 
 
Dan R.
Guest
Posts: n/a
 
      31st Dec 2007
Open the control toolbox and add a command button to your worksheet.
Then right-click your sheet tab, hit View Code and add this:

Private Sub CommandButton1_Click()
Cells.ClearContents
End Sub

--
Dan

On Dec 31, 11:05*am, mrhil...@gmail.com wrote:
> Hi,
>
> * *I'm not very knowledgeable on codes and all that intails. *What I'm
> trying to do with Microsoft Excel is create a spreadsheet using data
> validation. *I've gotten that part complete. *Now what i'm trying to
> do is add a "Clear" button so that the drop down data validation cells/
> menus will remain intact but the clear button will turn the cells
> blank so that the input user will be able to start over with the drop
> down menus. *Hope this makes sense. *Thanks for any help.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      31st Dec 2007
Record a macro when you select the range of cells to clear
then edit|clear|contents (or hit the delete key)
Then stop recording.



(E-Mail Removed) wrote:
>
> Hi,
>
> I'm not very knowledgeable on codes and all that intails. What I'm
> trying to do with Microsoft Excel is create a spreadsheet using data
> validation. I've gotten that part complete. Now what i'm trying to
> do is add a "Clear" button so that the drop down data validation cells/
> menus will remain intact but the clear button will turn the cells
> blank so that the input user will be able to start over with the drop
> down menus. Hope this makes sense. Thanks for any help.


--

Dave Peterson
 
Reply With Quote
 
mrhilder@gmail.com
Guest
Posts: n/a
 
      31st Dec 2007
On Dec 31, 12:25*pm, "Dan R." <Dan.R.Oa...@gmail.com> wrote:
> Open the control toolbox and add a command button to your worksheet.
> Then right-click your sheet tab, hit View Code and add this:
>
> Private Sub CommandButton1_Click()
> * *Cells.ClearContents
> End Sub
>
> --
> Dan
>
> On Dec 31, 11:05*am, mrhil...@gmail.com wrote:
>
> Dan, thanks for helping...I'm still not getting it to work. Here is the entire "Code" that I have now and its still showing errors, hopefully you canshow me whats wrong.


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Private Sub CommandButton1_Click()
Cells.ClearContents
End Sub

End Sub

Also, once this works is this code designed to clear all my cells or
just the ones with Data validation? Thats all I'm trying to do is
clear them not my titles, sub headings etc. Thanks a million
>
> > Hi,

>
> > * *I'm not very knowledgeable on codes and all that intails. *WhatI'm
> > trying to do with Microsoft Excel is create a spreadsheet using data
> > validation. *I've gotten that part complete. *Now what i'm trying to
> > do is add a "Clear" button so that the drop down data validation cells/
> > menus will remain intact but the clear button will turn the cells
> > blank so that the input user will be able to start over with the drop
> > down menus. *Hope this makes sense. *Thanks for any help.- Hide quoted text -

>
> - Show quoted text -


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      31st Dec 2007
First,
Cells.clearcontents
will clear all the cells on the worksheet. I'm not sure that's what you want!

Second, you don't want the other stuff--just this:
Private Sub CommandButton1_Click()
me.range("a1,b3,d3,e9:f10").ClearContents
End Sub

Change that a1,b3,d3,e9:f10 stuff to just the addresses that should be cleared.

(E-Mail Removed) wrote:
>
> On Dec 31, 12:25 pm, "Dan R." <Dan.R.Oa...@gmail.com> wrote:
> > Open the control toolbox and add a command button to your worksheet.
> > Then right-click your sheet tab, hit View Code and add this:
> >
> > Private Sub CommandButton1_Click()
> > Cells.ClearContents
> > End Sub
> >
> > --
> > Dan
> >
> > On Dec 31, 11:05 am, mrhil...@gmail.com wrote:
> >
> > Dan, thanks for helping...I'm still not getting it to work. Here is the entire "Code" that I have now and its still showing errors, hopefully you can show me whats wrong.

>
> Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> Private Sub CommandButton1_Click()
> Cells.ClearContents
> End Sub
>
> End Sub
>
> Also, once this works is this code designed to clear all my cells or
> just the ones with Data validation? Thats all I'm trying to do is
> clear them not my titles, sub headings etc. Thanks a million
> >
> > > Hi,

> >
> > > I'm not very knowledgeable on codes and all that intails. What I'm
> > > trying to do with Microsoft Excel is create a spreadsheet using data
> > > validation. I've gotten that part complete. Now what i'm trying to
> > > do is add a "Clear" button so that the drop down data validation cells/
> > > menus will remain intact but the clear button will turn the cells
> > > blank so that the input user will be able to start over with the drop
> > > down menus. Hope this makes sense. Thanks for any help.- Hide quoted text -

> >
> > - Show quoted text -


--

Dave Peterson
 
Reply With Quote
 
mrhilder@gmail.com
Guest
Posts: n/a
 
      31st Dec 2007
On Dec 31, 1:45*pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> First,
> Cells.clearcontents
> will clear all the cells on the worksheet. *I'm not sure that's what youwant!
>
> Second, you don't want the other stuff--just this:
> Private Sub CommandButton1_Click()
> * *me.range("a1,b3,d3,e9:f10").ClearContents
> End Sub
>
> Change that a1,b3,d3,e9:f10 stuff to just the addresses that should be cleared.
>
>
>
>
>
> mrhil...@gmail.com wrote:
>
> > On Dec 31, 12:25 pm, "Dan R." <Dan.R.Oa...@gmail.com> wrote:
> > > Open the control toolbox and add a command button to your worksheet.
> > > Then right-click your sheet tab, hit View Code and add this:

>
> > > Private Sub CommandButton1_Click()
> > > * *Cells.ClearContents
> > > End Sub

>
> > > --
> > > Dan

>
> > > On Dec 31, 11:05 am, mrhil...@gmail.com wrote:

>
> > > Dan, thanks for helping...I'm still not getting it to work. *Here isthe entire "Code" that I have now and its still showing errors, hopefully you can show me whats wrong.

>
> > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> > Private Sub CommandButton1_Click()
> > * *Cells.ClearContents
> > End Sub

>
> > End Sub

>
> > Also, once this works is this code designed to clear all my cells or
> > just the ones with Data validation? *Thats all I'm trying to do is
> > clear them not my titles, sub headings etc. *Thanks a million

>
> > > > Hi,

>
> > > > * *I'm not very knowledgeable on codes and all that intails. *What I'm
> > > > trying to do with Microsoft Excel is create a spreadsheet using data
> > > > validation. *I've gotten that part complete. *Now what i'm trying to
> > > > do is add a "Clear" button so that the drop down data validation cells/
> > > > menus will remain intact but the clear button will turn the cells
> > > > blank so that the input user will be able to start over with the drop
> > > > down menus. *Hope this makes sense. *Thanks for any help.- Hide quoted text -

>
> > > - Show quoted text -

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


Ok, no errors after I inserted that code. However now when I go to
"click" on the command button, my pointer turns into a fourway arrow
and it just wants me to "move" the button not actually press it to
clear. Any help with this problem?
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      31st Dec 2007
Make sure you have that code behind the worksheet that owns that commandbutton.

And make sure that you've toggled Design mode off.

It's a button on that same control toolbox toolbar.

(E-Mail Removed) wrote:
>
> On Dec 31, 1:45 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > First,
> > Cells.clearcontents
> > will clear all the cells on the worksheet. I'm not sure that's what you want!
> >
> > Second, you don't want the other stuff--just this:
> > Private Sub CommandButton1_Click()
> > me.range("a1,b3,d3,e9:f10").ClearContents
> > End Sub
> >
> > Change that a1,b3,d3,e9:f10 stuff to just the addresses that should be cleared.
> >
> >
> >
> >
> >
> > mrhil...@gmail.com wrote:
> >
> > > On Dec 31, 12:25 pm, "Dan R." <Dan.R.Oa...@gmail.com> wrote:
> > > > Open the control toolbox and add a command button to your worksheet.
> > > > Then right-click your sheet tab, hit View Code and add this:

> >
> > > > Private Sub CommandButton1_Click()
> > > > Cells.ClearContents
> > > > End Sub

> >
> > > > --
> > > > Dan

> >
> > > > On Dec 31, 11:05 am, mrhil...@gmail.com wrote:

> >
> > > > Dan, thanks for helping...I'm still not getting it to work. Here is the entire "Code" that I have now and its still showing errors, hopefully you can show me whats wrong.

> >
> > > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> > > Private Sub CommandButton1_Click()
> > > Cells.ClearContents
> > > End Sub

> >
> > > End Sub

> >
> > > Also, once this works is this code designed to clear all my cells or
> > > just the ones with Data validation? Thats all I'm trying to do is
> > > clear them not my titles, sub headings etc. Thanks a million

> >
> > > > > Hi,

> >
> > > > > I'm not very knowledgeable on codes and all that intails. What I'm
> > > > > trying to do with Microsoft Excel is create a spreadsheet using data
> > > > > validation. I've gotten that part complete. Now what i'm trying to
> > > > > do is add a "Clear" button so that the drop down data validation cells/
> > > > > menus will remain intact but the clear button will turn the cells
> > > > > blank so that the input user will be able to start over with the drop
> > > > > down menus. Hope this makes sense. Thanks for any help.- Hide quoted text -

> >
> > > > - Show quoted text -

> >
> > --
> >
> > Dave Peterson- Hide quoted text -
> >
> > - Show quoted text -

>
> Ok, no errors after I inserted that code. However now when I go to
> "click" on the command button, my pointer turns into a fourway arrow
> and it just wants me to "move" the button not actually press it to
> clear. Any help with this problem?


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      31st Dec 2007
And make sure you've allowed macros to run--you may need to change the security
setting and/or answer the prompt when the workbook is opened.

(E-Mail Removed) wrote:
>
> On Dec 31, 1:45 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > First,
> > Cells.clearcontents
> > will clear all the cells on the worksheet. I'm not sure that's what you want!
> >
> > Second, you don't want the other stuff--just this:
> > Private Sub CommandButton1_Click()
> > me.range("a1,b3,d3,e9:f10").ClearContents
> > End Sub
> >
> > Change that a1,b3,d3,e9:f10 stuff to just the addresses that should be cleared.
> >
> >
> >
> >
> >
> > mrhil...@gmail.com wrote:
> >
> > > On Dec 31, 12:25 pm, "Dan R." <Dan.R.Oa...@gmail.com> wrote:
> > > > Open the control toolbox and add a command button to your worksheet.
> > > > Then right-click your sheet tab, hit View Code and add this:

> >
> > > > Private Sub CommandButton1_Click()
> > > > Cells.ClearContents
> > > > End Sub

> >
> > > > --
> > > > Dan

> >
> > > > On Dec 31, 11:05 am, mrhil...@gmail.com wrote:

> >
> > > > Dan, thanks for helping...I'm still not getting it to work. Here is the entire "Code" that I have now and its still showing errors, hopefully you can show me whats wrong.

> >
> > > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> > > Private Sub CommandButton1_Click()
> > > Cells.ClearContents
> > > End Sub

> >
> > > End Sub

> >
> > > Also, once this works is this code designed to clear all my cells or
> > > just the ones with Data validation? Thats all I'm trying to do is
> > > clear them not my titles, sub headings etc. Thanks a million

> >
> > > > > Hi,

> >
> > > > > I'm not very knowledgeable on codes and all that intails. What I'm
> > > > > trying to do with Microsoft Excel is create a spreadsheet using data
> > > > > validation. I've gotten that part complete. Now what i'm trying to
> > > > > do is add a "Clear" button so that the drop down data validation cells/
> > > > > menus will remain intact but the clear button will turn the cells
> > > > > blank so that the input user will be able to start over with the drop
> > > > > down menus. Hope this makes sense. Thanks for any help.- Hide quoted text -

> >
> > > > - Show quoted text -

> >
> > --
> >
> > Dave Peterson- Hide quoted text -
> >
> > - Show quoted text -

>
> Ok, no errors after I inserted that code. However now when I go to
> "click" on the command button, my pointer turns into a fourway arrow
> and it just wants me to "move" the button not actually press it to
> clear. Any help with this problem?


--

Dave Peterson
 
Reply With Quote
 
mrhilder@gmail.com
Guest
Posts: n/a
 
      31st Dec 2007
On Dec 31, 3:08*pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> And make sure you've allowed macros to run--you may need to change the security
> setting and/or answer the prompt when the workbook is opened.
>
>
>
>
>
> mrhil...@gmail.com wrote:
>
> > On Dec 31, 1:45 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> > > First,
> > > Cells.clearcontents
> > > will clear all the cells on the worksheet. *I'm not sure that's whatyou want!

>
> > > Second, you don't want the other stuff--just this:
> > > Private Sub CommandButton1_Click()
> > > * *me.range("a1,b3,d3,e9:f10").ClearContents
> > > End Sub

>
> > > Change that a1,b3,d3,e9:f10 stuff to just the addresses that should becleared.

>
> > > mrhil...@gmail.com wrote:

>
> > > > On Dec 31, 12:25 pm, "Dan R." <Dan.R.Oa...@gmail.com> wrote:
> > > > > Open the control toolbox and add a command button to your worksheet.
> > > > > Then right-click your sheet tab, hit View Code and add this:

>
> > > > > Private Sub CommandButton1_Click()
> > > > > * *Cells.ClearContents
> > > > > End Sub

>
> > > > > --
> > > > > Dan

>
> > > > > On Dec 31, 11:05 am, mrhil...@gmail.com wrote:

>
> > > > > Dan, thanks for helping...I'm still not getting it to work. *Here is the entire "Code" that I have now and its still showing errors, hopefully you can show me whats wrong.

>
> > > > Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> > > > Private Sub CommandButton1_Click()
> > > > * *Cells.ClearContents
> > > > End Sub

>
> > > > End Sub

>
> > > > Also, once this works is this code designed to clear all my cells or
> > > > just the ones with Data validation? *Thats all I'm trying to do is
> > > > clear them not my titles, sub headings etc. *Thanks a million

>
> > > > > > Hi,

>
> > > > > > * *I'm not very knowledgeable on codes and all that intails.*What I'm
> > > > > > trying to do with Microsoft Excel is create a spreadsheet using data
> > > > > > validation. *I've gotten that part complete. *Now what i'm trying to
> > > > > > do is add a "Clear" button so that the drop down data validationcells/
> > > > > > menus will remain intact but the clear button will turn the cells
> > > > > > blank so that the input user will be able to start over with thedrop
> > > > > > down menus. *Hope this makes sense. *Thanks for any help.- Hide quoted text -

>
> > > > > - Show quoted text -

>
> > > --

>
> > > Dave Peterson- Hide quoted text -

>
> > > - Show quoted text -

>
> > Ok, no errors after I inserted that code. *However now when I go to
> > "click" on the command button, my pointer turns into a fourway arrow
> > and it just wants me to "move" the button not actually press it to
> > clear. *Any help with this problem?

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


Thanks for all the help!!!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
need VBA to clear dependent data validation lists in several rows PerplexedPanda Microsoft Excel Programming 4 9th May 2008 10:50 PM
Button to clear all data in a record =?Utf-8?B?TWFheA==?= Microsoft Access 2 4th Feb 2007 08:25 PM
Clear Form button to work despite validation conflicts =?Utf-8?B?c21pbGVlOF8yOA==?= Microsoft Access 3 12th Jan 2006 10:07 PM
question data validation and delete/clear behavior =?Utf-8?B?SmVmZiBIaWdnaW5z?= Microsoft Excel Programming 0 23rd Jan 2005 08:09 PM
Clear data button for workbooks takatross Microsoft Excel Discussion 3 15th Oct 2003 03:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:31 AM.