ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CLEAR FIELD TEXT ON CLICK? (https://www.excelbanter.com/excel-programming/411308-clear-field-text-click.html)

KLZA

CLEAR FIELD TEXT ON CLICK?
 
Hi. I have a form that I'd like to automatically clear when it's
clicked for text input. Is this possible in excel?

JW[_2_]

CLEAR FIELD TEXT ON CLICK?
 
On May 21, 12:36*pm, KLZA wrote:
Hi. *I have a form that I'd like to automatically clear when it's
clicked for text input. *Is this possible in excel?


Private Sub TextBox1_Enter()
Me.TextBox1.Text = ""
End Sub

KLZA

CLEAR FIELD TEXT ON CLICK?
 
Thanks. But how do I apply this to a field? I'm using a field
instead of a text box.

JW wrote:
On May 21, 12:36�pm, KLZA wrote:
Hi. �I have a form that I'd like to automatically clear when it's
clicked for text input. �Is this possible in excel?


Private Sub TextBox1_Enter()
Me.TextBox1.Text = ""
End Sub


JW[_2_]

CLEAR FIELD TEXT ON CLICK?
 
On May 21, 12:42Â*pm, KLZA wrote:
Thanks. Â*But how do I apply this to a field? Â*I'm using a field
instead of a text box.



JW wrote:
On May 21, 12:36�pm, KLZA wrote:
Hi. �I have a form that I'd like to automatically clear when it's
clicked for text input. �Is this possible in excel?


Private Sub TextBox1_Enter()
Â* Â* Me.TextBox1.Text = ""
End Sub- Hide quoted text -


- Show quoted text -


Oh. I was assuming you were talking about a UserForm. Are you
referring to a cell on a worksheet? If so, you can do something like
this, assuming the cell you want to clear is A2. This code would go
in the sheet's code module. Right click the sheet tab and select View
Code. Then paste this in there.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$2" Then Target.ClearContents
End Sub


All times are GMT +1. The time now is 06:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com