View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Can vlookup be used to retrieve multiple matches

Try this macro where you are asked for the NUMBER such as 123
Sub matchemall()
wo = "WO" & InputBox("Enter workorder num")
lr = Cells(Rows.Count, "a").End(xlUp).Row
With Worksheets("sheet5").Range("a1:a" & lr)
Set c = .Find(wo, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
ms = ms & " & " & c.Offset(, 1)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
MsgBox wo & " used " & Right(ms, Len(ms) - 2)
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
oups.com...
Say, I have a worksheet that has Column A for work orders, Column B
for parts

A work order may contain many parts on different rows:

Column A Column B
WO123 PN5
WO123 PN6
WO123 PN7
WO121 PN9
WO122 PN4
WO122 PN7
etc

I want to automatically "look up" a work order and "import" the parts
used into another worksheet - to create a "flat/horizontal" statement
like "WO122 used PN4 and PN7". How do I do this?