Unprotecting a sheet once a text box is selected

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,714
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.
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,588
Presuming the textbox is located on the sheet ... only ActiveX Textboxes are allowed to be used there.
Regular Textboxes are used on UserForm.

If ActiveX on Sheet, use the Sheet Module :

VBA Code:
Option Explicit

Private Sub TextBox1_GotFocus()
MsgBox "Hi"
End Sub

'Replace MsgBox with your macro or a call to a macro

Private Sub TextBox1_LostFocus()
MsgBox "Bye"
End Sub


If Textbox on Form, in the Form Code Window:

Code:
Option Explicit

Private Sub TextBox2_Enter()
MsgBox "Hi"
End Sub

Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Bye"
End Sub
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,714
What do you mean by "Regular text boxes are used on user form" as I have my regular text box on the sheet?
 

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,588
Go to DEVELOPER tab, select INSERT. From the small window that pops up, the REGULAR TEXTBOX is greyed out.

The only thing to select is ACTIVEX TEXTBOX.

How did you manage to paste a REGULAR TEXTBOX ?
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,267
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

Umm.....Insert>>Text>>TextBox ??
 

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,588
Can you post a pic of what you are looking at ?
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,714

ADVERTISEMENT

I think I entered it as Michael said
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,213
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Can you post a pic of what you are looking at ?
You can also place a "regular" (not Active-X) Textbox on a sheet programatically:
VBA Code:
Sub RegularTextBox()
Dim TBx As Shape
Set TBx = ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 60, 40, 120, 120)
MsgBox TypeName(TBx)
End Sub
 

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,588
That is FABULOUS !!

I just learned something new today. Thank you.
 

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,588
I'm still interested learning how to paste a Regular Textbox on a sheet.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,183
Messages
5,527,289
Members
409,757
Latest member
uzamr

This Week's Hot Topics

Top