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”
x = x + 1
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: