View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Auto fill text boxes in user form by inputting data in another

Assume Textbox1 is where you enter the data

Data is on Sheet1, Range A1:J50

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim rng as Range, rng1 as Range, res as Variant
set rng = Worksheets("Sheet1").Range("A1:J50").columns(1)
res = Application.Match(Textbox1.Text, rng,0)
if not iserror(res) then
set rng1 = rng(res)
Textbox2.Text = rng1.offset(0,1)
Textbox3.Text = rng1.offset(0,3)
Textbox4.Text = rng1.offset(0,7)
Textbox5.Text = rng1.Offset(0,10)
Else
msgbox "Not found in database
End if
End Sub

This assumes the value in Textbox1 is alphanumeric. If it is numeric and
the entries in the cells in the lookup column are numeric then you would
need
res = Application.Match(cdbl(Textbox1.Text), rng,0)

--
Regards,
Tom Ogilvy



--
Regards,
Tom Ogilvy
"Finny33 " wrote in message
...
I have a user-form set up which has 5 text boxes which need to have text
put in them. I also have a page with all the info required for the above
boxes so I am trying to find some way that I can input data into one of
the boxes and the other boxes will then be automatically filled in with
the info from the page mentioned. The info is a database list with a
separate row for each entry and there are 10 columns with 10 different
parts of the data.
Have I explained this properly and, if so, can anyone help ?
Thanks in advance,

JOHN


---
Message posted from http://www.ExcelForum.com/