PC Review


Reply
Thread Tools Rate Thread

Create a Clear button to clear unprotected cells

 
 
Jcraig713
Guest
Posts: n/a
 
      26th Nov 2007
Hello. I spent a while searcing through historical posts for this answer but
I could not get anything suggested to work on my sheet. I think this is more
than likely a pretty easy thing for experienced users (of course not me!) )

I have a simple worksheet (no macros, forms etc.). I created a clear button
and when I click on it, I want Cell F3 and range E6 - E 13 (unprotected
cells; the rest of the sheet is protected) to clear and then refocus on cell
F3.

I used the following code on the clear button:

Private Sub ClearButton1_Click()

Dim cell As Range
Range("E6:E13").Select
Range("E6").Activate
For Each cell In Selection
If cell.Locked = False Then
cell.ClearContents
End If
Next
End Sub

How do I get the cell F3 to regain the focus on click?
 
Reply With Quote
 
 
 
 
Zone
Guest
Posts: n/a
 
      26th Nov 2007
How about this? James

Private Sub ClearButton1_Click()
Range("E6:E13").ClearContents
Range("F3").Select
ActiveCell.ClearContents
End Sub

"Jcraig713" <(E-Mail Removed)> wrote in message
news:475FBA28-F46E-4066-8060-(E-Mail Removed)...
> Hello. I spent a while searcing through historical posts for this answer
> but
> I could not get anything suggested to work on my sheet. I think this is
> more
> than likely a pretty easy thing for experienced users (of course not me!)
> )
>
> I have a simple worksheet (no macros, forms etc.). I created a clear
> button
> and when I click on it, I want Cell F3 and range E6 - E 13 (unprotected
> cells; the rest of the sheet is protected) to clear and then refocus on
> cell
> F3.
>
> I used the following code on the clear button:
>
> Private Sub ClearButton1_Click()
>
> Dim cell As Range
> Range("E6:E13").Select
> Range("E6").Activate
> For Each cell In Selection
> If cell.Locked = False Then
> cell.ClearContents
> End If
> Next
> End Sub
>
> How do I get the cell F3 to regain the focus on click?



 
Reply With Quote
 
Jcraig713
Guest
Posts: n/a
 
      26th Nov 2007
Thanks so much.... I am flying now!

janell

"Zone" wrote:

> How about this? James
>
> Private Sub ClearButton1_Click()
> Range("E6:E13").ClearContents
> Range("F3").Select
> ActiveCell.ClearContents
> End Sub
>
> "Jcraig713" <(E-Mail Removed)> wrote in message
> news:475FBA28-F46E-4066-8060-(E-Mail Removed)...
> > Hello. I spent a while searcing through historical posts for this answer
> > but
> > I could not get anything suggested to work on my sheet. I think this is
> > more
> > than likely a pretty easy thing for experienced users (of course not me!)
> > )
> >
> > I have a simple worksheet (no macros, forms etc.). I created a clear
> > button
> > and when I click on it, I want Cell F3 and range E6 - E 13 (unprotected
> > cells; the rest of the sheet is protected) to clear and then refocus on
> > cell
> > F3.
> >
> > I used the following code on the clear button:
> >
> > Private Sub ClearButton1_Click()
> >
> > Dim cell As Range
> > Range("E6:E13").Select
> > Range("E6").Activate
> > For Each cell In Selection
> > If cell.Locked = False Then
> > cell.ClearContents
> > End If
> > Next
> > End Sub
> >
> > How do I get the cell F3 to regain the focus on click?

>
>
>

 
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
Identify unprotected cells in protected sheet and clear their cont =?Utf-8?B?TmV6UmhvZGVz?= Microsoft Excel Programming 9 15th Sep 2006 07:26 PM
Macro to clear contents of unprotected cells AND drop down boxes =?Utf-8?B?SkIyMDEw?= Microsoft Excel Misc 3 30th Mar 2006 10:13 AM
clear contents cells of unprotected cells =?Utf-8?B?RWQ=?= Microsoft Excel Programming 6 12th Jan 2006 06:09 PM
Clear contents of unprotected cells in entire workbook with a macr =?Utf-8?B?Rmlubkdpcmw=?= Microsoft Excel Programming 1 29th Jun 2005 05:32 PM
Create a button to Clear Cells =?Utf-8?B?dGFtYXRvNDM=?= Microsoft Excel Misc 3 16th May 2005 02:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:36 AM.