Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Update Text Box Value
Maybe a simple question
Can anyone tell me how I go about updating other text boxes from an input in one text box ?? I have an emloyee number that links to personnel information about an individual .. I would like to enter a pay number in one box ... click a button and their name etc is presented in the other boxes ... Can anyone enlighten me please Many thanks |
#2
|
|||
|
|||
Update Text Box Value
Hi Alan,
'----------------------------------- Maybe a simple question Can anyone tell me how I go about updating other text boxes from an input in one text box ?? I have an emloyee number that links to personnel information about an individual .. I would like to enter a pay number in one box ... click a button and their name etc is presented in the other boxes ... Can anyone enlighten me please Many thanks '------------------------------------ Assume that the employee data is held in a range which you have named "Table". Assume that column 1 of the table holds the employee ID numbers; column 2 holds employee data, say Name, column 3 gives the employee title, and so on. Assume further that the first table row comprises a header row. From the Control Toolbox add as many textboxes as you have columns of data to be read, Assume that these text boxes are named: TextBox1, TextBox2 ...TextBoxn. Right-click the worksheet tab and paste the following code: '==================== Private Sub ListBox1_GotFocus() Dim rng As Range Set rng = Range("Table").Columns(1).Cells Set rng = rng.Offset(1).Resize(rng.Cells.Count - 1) ListBox1.List() = rng.Value End Sub '<<==================== '==================== Private Sub ListBox1_Change() Dim myval As Variant Dim rng As Range Set rng = Range("Table") myval = ListBox1.Value TextBox1.Value = Application.VLookup(myval, rng, 2, 0) TextBox2.Value = Application.VLookup(myval, rng, 3, 0) TextBox3.Value = Application.VLookup(myval, rng, 4, 0) End Sub '<<==================== Insert an additional line of code for each additional text box, using the name of the additional text box and changing the penultimate VLookup parameter to accord with the Table's required data column. Alt-F11 to return to the worksheet. Exit from design mode, by clickimg the Control Toolbox (top left) set square icon, close the Control ToolBox. Now, selecting an id number from the list box will update each of the text boxes with data relating to the relevant employee. --- Regards, Norman |
#3
|
|||
|
|||
Update Text Box Value
Hi Alan,
From the Control Toolbox add as many textboxes as you have columns of data to be read, Should read: From the Control Toolbox, add a TextBox and as many textboxes as you have columns of data to be read. Assume the TextBox is named TextBox1. --- Regards, Norman "Norman Jones" wrote in message ... Hi Alan, '----------------------------------- Maybe a simple question Can anyone tell me how I go about updating other text boxes from an input in one text box ?? I have an emloyee number that links to personnel information about an individual .. I would like to enter a pay number in one box ... click a button and their name etc is presented in the other boxes ... Can anyone enlighten me please Many thanks '------------------------------------ Assume that the employee data is held in a range which you have named "Table". Assume that column 1 of the table holds the employee ID numbers; column 2 holds employee data, say Name, column 3 gives the employee title, and so on. Assume further that the first table row comprises a header row. From the Control Toolbox add as many textboxes as you have columns of data to be read, Assume that these text boxes are named: TextBox1, TextBox2 ...TextBoxn. Right-click the worksheet tab and paste the following code: '==================== Private Sub ListBox1_GotFocus() Dim rng As Range Set rng = Range("Table").Columns(1).Cells Set rng = rng.Offset(1).Resize(rng.Cells.Count - 1) ListBox1.List() = rng.Value End Sub '<<==================== '==================== Private Sub ListBox1_Change() Dim myval As Variant Dim rng As Range Set rng = Range("Table") myval = ListBox1.Value TextBox1.Value = Application.VLookup(myval, rng, 2, 0) TextBox2.Value = Application.VLookup(myval, rng, 3, 0) TextBox3.Value = Application.VLookup(myval, rng, 4, 0) End Sub '<<==================== Insert an additional line of code for each additional text box, using the name of the additional text box and changing the penultimate VLookup parameter to accord with the Table's required data column. Alt-F11 to return to the worksheet. Exit from design mode, by clickimg the Control Toolbox (top left) set square icon, close the Control ToolBox. Now, selecting an id number from the list box will update each of the text boxes with data relating to the relevant employee. --- Regards, Norman |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Resetting default row height to allow display of wrapped text | New Users to Excel | |||
I want to link, not just copy,Word source text to a text box in Ex | Excel Worksheet Functions | |||
Finding Specific Text in a Text String | Excel Worksheet Functions | |||
SUMPRODUCT vs Text??? | Excel Worksheet Functions | |||
Read Text File into Excel Using VBA | Excel Discussion (Misc queries) |