Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Alan
 
Posts: n/a
Default 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   Report Post  
Norman Jones
 
Posts: n/a
Default 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   Report Post  
Norman Jones
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resetting default row height to allow display of wrapped text Stilson New Users to Excel 2 August 30th 05 12:56 AM
I want to link, not just copy,Word source text to a text box in Ex Carrie K Excel Worksheet Functions 0 August 12th 05 07:58 PM
Finding Specific Text in a Text String Peter Gundrum Excel Worksheet Functions 9 April 10th 05 07:21 PM
SUMPRODUCT vs Text??? Ken Excel Worksheet Functions 2 April 9th 05 07:21 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 06:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"