Display Message in One TextBox Based on Entry in Another TextBox

Hello, sir or madam
Your example is great but I am still confused as to how this would work. I am just wanting to create a textbox2 that will display a message when I type a part number in another textbox1 on a userform. Text-box 2 will have a vlookup formula that says that “if textbox 1 is available in the excel worksheet then show part is available in textbox2. I was able to create this in the following worksheet attached. But would like to do the same on the userform. Please note the sheet has formula.

We describe below the steps to solve this problem in Microsoft Excel.

First we enter data into our MS-Excel worksheet
Next we start the Visual Basic Editor by clicking on the Developer Tab and selecting Visual Basic
In the Visual Basic Editor window we click on insert and select user form
On the user-form we place labels ‘Part No’ and ‘Message’. We also place two Text Boxes – TextBox1 and TextBox2
Next we place a command button and code it as follows:
Private Sub CommandButton1_Click()
‘Define a starting row
x = 2
Do While Cells(x, 1) <> “”
If TextBox1.Text = Cells(x, 1) And Cells(x, 2) > 0 Then
TextBox2.Text = “Available”
End If
x = x + 1
End Sub
Of course, you could further refine the code to display messages like ‘Not Available’ or ‘No such Part No exists!’.

Watch the video below to learn how to display text or message in one Text Box based on an entry in another Text Box:

2 thoughts on “Display Message in One TextBox Based on Entry in Another TextBox

  1. Hello,

    Well i am working for HR department.
    We interview candidates and store there hard copy of their CV’s.
    Now i want to create a CV Library where i can store the candidates CV mentioned their details and the remarks given by the management.
    I want to create a search area so that when i want to search for a specific candite all the data can be view accordingly.

    Your kind support for the same will be highly appriciated.

    Thanks and Regards
    Baqir Lakhani

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.