View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Zone[_3_] Zone[_3_] is offline
external usenet poster
 
Posts: 373
Default Create a Clear button to clear unprotected cells

How about this? James

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

"Jcraig713" wrote in message
...
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!)
:o)

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?