Displaying text in form based on previous slection

  • Thread starter Thread starter Ben Allen
  • Start date Start date
B

Ben Allen

I have a form with a drop-down list in which the user picks the tour
refrence number. Is it then possible for 2 tect boxes (country and place) to
be displayed (non-editable) accordidng to which ref. the user picked? i know
i could use lookup in the spreadsheet but wasnt sure about userforms. The
spreadsheet containg the infomation i like this:
Tour Ref Country Place
ET01 SPAIN La Coruna
ET02 SPAIN Santander


etc,
thank you for any help.
--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"
 
Textbox1.Text = Application.Vlookup(combobox1.Value, _
Worksheets("Data").Range("A1:C200"),2,False)
Textbox2.Text = Application.Vlookup(combobox1.Value, _
Worksheets("Data").Range("A1:C200"),3,False)
 
Ben,

In the list box change event.

Assuming that ET01 is in the first column, SPAIN the second, La Corun
the third, and that there are now empty rows.

Private Sub ListBox1_Change()
Dim intNextRow As Integer

TextBox1 = ""
TextBox2 = ""

intNextRow = 1

Do
If Sheets(1).Cells(intNextRow, 1) = ListBox1.Value Then
TextBox1 = Sheets(1).Cells(intNextRow, 2)
TextBox2 = Sheets(1).Cells(intNextRow, 3)
Exit Do
End If

intNextRow = intNextRow + 1
Loop Until Sheets(1).Cells(intNextRow, 1) = ""
End Sub
 
thanks, i get no errors with this code but nothing is displayed in the
texboxes. I have changed the names to reflect the textboxes, is there
anything else i need to do?
Thanks again

--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"
 
Pybal? ?

--
Regards,
Tom Ogilvy

Ben Allen said:
thanks, i get no errors with this code but nothing is displayed in the
texboxes. I have changed the names to reflect the textboxes, is there
anything else i need to do?
Thanks again

--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"
 
Tom said:
Textbox1.Text = Application.Vlookup(combobox1.Value, _
Worksheets("Data").Range("A1:C200"),2,False)
Textbox2.Text = Application.Vlookup(combobox1.Value, _
Worksheets("Data").Range("A1:C200"),3,False)
Hi Tom,
I tried this method but am unsure where the actual code needs to go, under
what event etc.
Thanks for your help
--
Cheers,
Ben

Remove your.tonsils to reply
"You only live once but if you do it right once is enough!"
 

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