View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
L. Howard Kittle L. Howard Kittle is offline
external usenet poster
 
Posts: 698
Default Is there a macro for returning multiple values through a Vlookup?

Hi Anshu,

Give this a test, you will have to change the ranges in the code to suit
your sheet or set up an example on your sheet to match the code ranges.
Can be tweeked to suit of course.

Sub TheProjects()
Dim i As Long
Dim j As Variant
Dim Pro As Range
Dim Pha As Range
Dim cell As Range

i = Range("I9").Value ' Type Project number in I9
j = Range("J9").Value ' Type Phase number in J9
Set Pro = Range("B9:B12") ' List of Project# range
Set Pha = Range("C9:C12") ' List of Phase numbers range

'Copies the Pro and Pha number into the next available row in Column I and J
Range("I9:J9").Copy Range("K100").End(xlUp).Offset(1, -2).Resize(1, 2)

'Gathers the info for Pro range and Pha range and copies to the
'next available row in column K
For Each cell In Pro
If cell.Value = i And cell.Offset(0, 1).Value = j Then
cell.Offset(0, 2).Resize(1, 4).Copy
Range("K100").End(xlUp).Offset(1, 0)
End If
Next
End Sub

HTH
Regards,
Howard

"anshu minocha" wrote in message
...
Foe eg: Sheet2 contains:

Project# Phase Sp# Details status Manager ...
1234 1-0110 N80 abc Test am
1234 1-0210 N97 def Incom bd
1234 2-0210 N45 lmn Test cf
1234 1-0110 N67 jkl Com er


Sheet1 contains:

Project# Phase SP# Status Manager
1234 1-0110

The above 2 values are inserted by the user:
Now: On running the macro:

the sheet 1 should be populated with all the records for phase 1-0110
Desired output:

Project# Phase Sp# Status Manager
1234 1-0110 N80 Test am
N65 Com er

Any help would be greatly appreciated!!!
Thanks