ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto fill text boxes in user form by inputting data in another (https://www.excelbanter.com/excel-programming/309749-auto-fill-text-boxes-user-form-inputting-data-another.html)

Finny33

Auto fill text boxes in user form by inputting data in another
 
I have a user-form set up which has 5 text boxes which need to have tex
put in them. I also have a page with all the info required for the abov
boxes so I am trying to find some way that I can input data into one o
the boxes and the other boxes will then be automatically filled in wit
the info from the page mentioned. The info is a database list with
separate row for each entry and there are 10 columns with 10 differen
parts of the data.
Have I explained this properly and, if so, can anyone help ?
Thanks in advance,

JOH

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


Tom Ogilvy

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/





All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com