Delete text from text box

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a text box on my spreadsheet with some text in it, "Please type notes here", and when I click in it, I want the text to disappear. Is there a way to do this?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I just had an idea. A standard textbox works but I need it to delete the contents if it contains the phrase "Please type notes here", but if it doesn't, not to delete the contents as it may have been previously typed over. I can assign a macro to the text box but I don't know the code that would achieve this. Could someone help me please?
 
Last edited:
Upvote 0
It must be with an ActiveX Control textbox

Try this

Code:
Private Sub TextBox1_GotFocus()
  If TextBox1 = "Please type notes here" Then
    TextBox1 = ""
  End If
End Sub


Private Sub TextBox1_LostFocus()
  If TextBox1 = "" Then
    TextBox1 = "Please type notes here"
  End If
End Sub

Additionally in the Value property of the Textbox put this: "Please type notes here"
 
Last edited:
Upvote 0
I tried using an active x text box but I need it to auto expand down with more text and I couldn't get it to do that.
 
Upvote 0
I tried using an active x text box but I need it to auto expand down with more text and I couldn't get it to do that.


How to expand?
Do you want to use a Listbox or a combobox?


Or do you want to put more lines in a single textbox?

Change EnterKeyBehavior property to True

Change Multiline property to True
 
Last edited:
Upvote 0
I tried a text box with those settings but it won't get any larger as more lines are added. The text is just pushed up out of view the more times you hit enter. I need it to expand so all text is visible.
 
Upvote 0
I tried a text box with those settings but it won't get any larger as more lines are added. The text is just pushed up out of view the more times you hit enter. I need it to expand so all text is visible.

But that is another thread.
The main thread was to erase the text. What I sent you worked. I would like you to comment on this thread.


With pleasure I follow other threads, but you should close the first thread.

Change Autosize property to True
 
Upvote 0
Sorry about that Dante, I will try and ask everything in the original post for a thread in future.
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,749
Members
449,050
Latest member
excelknuckles

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