View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Vlookup on second WorkBook

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