![]() |
Create a Clear button to clear unprotected cells
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? |
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? |
Create a Clear button to clear unprotected cells
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" 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? |
All times are GMT +1. The time now is 09:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com