Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:54:31+00:00 2026-05-28T05:54:31+00:00

You know how sometimes you see text in an input field prompting for an

  • 0

You know how sometimes you see text in an input field prompting for an answer? When you click it, it goes away, but comes back if you deselect without having typed anything.

How do I accomplish this in an Excel text box? Can this be done at all?

I think I could accomplish this if I attach a click macro to the text box and the macro can be able to tell what text box was clicked, but the problem with the click macro is it won’t let you select the object first, so you have no idea what was clicked. And I don’t want to hard code the text box name in the click macro code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:54:32+00:00Added an answer on May 28, 2026 at 5:54 am

    I think you’re referring to a “placeholder” in a UserForm. The two tricks that I use to achieve this are the “tag” property and Enter and Exit events. First, create your sub modules that will fire upon Enter (focus) and Exit (blur).

    Sub TB_enter(TB_name)
        If Len(Me.Controls(TB_name).Tag) = 0 Then
            Me.Controls(TB_name).Tag = Me.Controls(TB_name).Value
            Me.Controls(TB_name).Value = vbNullString
        End If
    End Sub
    Sub TB_exit(TB_name)
        If Len(Me.Controls(TB_name).Value) = 0 Then
            Me.Controls(TB_name).Value = Me.Controls(TB_name).Tag
            Me.Controls(TB_name).Tag = vbNullString
        End If
    End Sub
    

    Next, for each instance of your textbox on your userform, double click on the textbox while in View Object mode. This will automatically create a Private Sub for the change event. Head to the upper right hand corner of the toolbar and change the “Change” drop down list to “Enter”. This will create a new Private Sub for the Enter event. Repeat this process again, but select “Exit” to create the Exit event. Now, simply copy the following code into the Enter and Exit events respectively (I’ve used the default name for the first textbox, but this is name independent when calling the events).

    Private Sub TextBox1_Enter()
        TB_enter ActiveControl.Name
    End Sub
    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
        TB_exit ActiveControl.Name
    End Sub
    

    If you are placing these calls in an external module, simply replace “Me” with the name of the UserForm.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I know a file is not so deep away, but a very dense
Does anyone know why sometimes when you right click on an image in a
I know that recursion is sometimes a lot cleaner than looping, and I'm not
I know that the compiler will sometimes initialize memory with certain patterns such as
Sometimes I've made a namespace in C# (I don't know if the problem is
We all know T-SQL's string manipulation capabilities sometimes leaves much to be desired... I
I want to know what the best practice is for passing values (sometimes multiple
I know it happens sometime before Load, but during what event exactly?
Sometimes I'd like to copy only the visible text from an outline-mode buffer in
I often see examples of using the keyword this in jquery. Sometimes I see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.