Create a Clear button to clear unprotected cells

J

Jcraig713

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!) :blush:)

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?
 
Z

Zone

How about this? James

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

Jcraig713

Thanks so much.... I am flying now!

janell

Zone said:
How about this? James

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top