CLEAR FIELD TEXT ON CLICK?

  • Thread starter Thread starter KLZA
  • Start date Start date
K

KLZA

Hi. I have a form that I'd like to automatically clear when it's
clicked for text input. Is this possible in excel?
 
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
 
Thanks. But how do I apply this to a field? I'm using a field
instead of a text box.
 
Thanks.  But how do I apply this to a field?  I'm using a field
instead of a text box.





- 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top