Display Message in One TextBox Based on Entry in Another TextBox

Excel 2007 Excel 2003 Macros Excel 2007 Macros Excel 2003 Excel 2010






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. Textbox 2 will have a vloopup formula that says that "if textbox 1 is availale 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.
Thanks.
Charles

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 TextBoxes - 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
    Loop
    End Sub

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



Excel 2007 Excel 2003 Macros Excel 2007 Macros Excel 2003 Excel 2010