Vlookup on second WorkBook
Thanks
The code below is on the UserForm EmployeeList. When I click on the Edit
Button (which runs the code below) it takes me to the other WorkBook
(EmployeeList.xls) and runs code on that WorkBook which allows one to edit
the selected name. Then I need to come back to the original WorkBook
(Vacation - Leave Book Master.xls) and UserForm EmployeeList. Following your
advice I changed Unload EmployeeList to EmployeeList.Hide but it still did
not return me to Vacation - Leave Book Master.xls
"Tom Ogilvy" wrote in message
...
I am guessing the code is in the code module for the userform named
EmployeeList.
try changing
Unload EmployeeList
to
EmployeeList.Hide
--
Regards,
Tom Ogilvy
"Patrick Simonds" wrote in message
...
Thank you below you will see my final code. I could not get it to work by
using the ListBox Index but was able to get around that by creating a
TextBox which contained the ListBox value. Was wondering if you could
explain why last 2 lines of my code do not work. I should explain that
when I search out the TextBox1 value in the other WorkBook it causes a
macro to run allowing me to edit the selected name.
Private Sub Edit_Name_Click()
Unload EmployeeList
Dim rng As Range, rng1 As Range
Dim sStr As String
Set rng =
Workbooks("EmployeeList.xls").Worksheets("Employee _List").Cells
sStr = Me.TextBox1.Value
Set rng1 = rng.Find(What:=sStr, _
After:=Range("IV65536"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng1 Is Nothing Then
Workbooks("EmployeeList.xls").Activate
ActiveWorkbook.Worksheets("Employee_List").Activat e
rng1.Select
Else
MsgBox sStr & " not found"
End If
Workbooks("Vacation - Leave Book Master.xls").Activate
EmployeeList.Show
End Sub
|