View Single Post
  #3   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

Private Sub Edit_Click()
Dim rng as Range, rng1 as range
if me.Listbox1.ListIndex < -1 then
set rng = Workbooks("Baker").Worksheets("names").Cells
sStr = me.Listbox1.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
MsgBox sStr & " found at " & rng.Address
Else
MsgBox sStr & " not found"
End If
End Sub


You can modify
set rng = Workbooks("Baker").Worksheets("names").Cells

to look at a smaller range and
LookAt:=xlWhole to xlPart if the name is not the only value in the cell.

change LookIn:=xlformulas to xlValues if the names are produced by formulas.

--
Regards,
Tom Ogilvy


"Patrick Simonds" wrote in message
...
I have two workbooks Able and Baker. When I click on a cell in Able a
UserForm is displayed. On this UserForm I click on a name (from a list of
names) in ListBox1. Then I want to click on a button labeled Edit which
will take me to WorkBook Baker (worksheet called Names) and select the cell
which contains the name I selected in ListBox1. I just can not figure out
what code to assign to the Edit button to make this happen.