ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accesing a second workbook (https://www.excelbanter.com/excel-programming/358514-accesing-second-workbook.html)

Patrick Simonds

Accesing a second workbook
 
I have a UserForm which is called from Workbook1. The userform has a LiskBox
which is populated from a range of cells on Workbook2, worksheet named
Employees.

What I would like to do is include some Textboxes which are also populated
from Workbook2, based on what is selected in the Listbox. The ListBox data
comes from Column A (combined First and Last name) and column B is the First
Name only, column C Is last Name only and column D is department code.

So I guess what I need is code that, while not making Worbook2 active, will
find the value selected in the Lisbox and then select the source cell on
Workbook2.



Jim Rech

Accesing a second workbook
 
Something like this perhaps:

With Workbooks("Book2.xls").Worksheets("Sheet1")
TextBox1.Text = .Range("A1").Value
TextBox2.Text = .Range("A2").Value
End With

--
Jim
"Patrick Simonds" wrote in message
...
|I have a UserForm which is called from Workbook1. The userform has a
LiskBox
| which is populated from a range of cells on Workbook2, worksheet named
| Employees.
|
| What I would like to do is include some Textboxes which are also populated
| from Workbook2, based on what is selected in the Listbox. The ListBox data
| comes from Column A (combined First and Last name) and column B is the
First
| Name only, column C Is last Name only and column D is department code.
|
| So I guess what I need is code that, while not making Worbook2 active,
will
| find the value selected in the Lisbox and then select the source cell on
| Workbook2.
|
|




All times are GMT +1. The time now is 03:53 PM.

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