Unprotecting a sheet once a text box is selected

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Can you unprotect a sheet once a text box is selected and then reprotect it again when it is unselected?

I do not want to use active x text boxes, just normal text boxes.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I thought of a way to do it. I could lock the area from about 7 rows below the table to the top of the sheet. Then I could have a label saying to type notes below the locked area. Just not sure how to code it.
 
Upvote 0
You can lock a range of cells, but it won't take effect until you protect the sheet....then you won't be able to type notes into that protected sheet !!
 
Upvote 0
Can you unprotect a sheet once a text box is selected and then reprotect it again when it is unselected?

I do not want to use active x text boxes, just normal text boxes.


?

VBA Code:
Sub TextBox1_Click()
    Unprotect
    ActiveSheet.Shapes("TextBox 1").Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Protect
End Sub
 
Upvote 0
How would you select the text box if the workbook is locked?
 
Last edited:
Upvote 0
You can't.....you must unprotect the sheet first...note the unprotect line in Dataluvers code
 
Upvote 0
Here's a workaround :

VBA Code:
Option Explicit

Sub TextBox1_Click()
    Unprotect
    ActiveSheet.Shapes("TextBox 1").Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Application.ScreenUpdating = False
        If Me.Range("A1:Z20").Select Then
            Beep
            Me.Range("A21").Select
            Exit Sub
        End If
    Application.ScreenUpdating = True
  
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,807
Messages
6,121,679
Members
449,047
Latest member
notmrdurden

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top