View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben[_2_] Gord Dibben[_2_] is offline
external usenet poster
 
Posts: 621
Default Query regarding any lookup function

Where do you want the results placed?

Some code by Don Guillet to return results to one cell..........C1

Option Explicit
Sub SAS_filternumbersfornames()
Dim mv As String
Dim mc As Long
Dim i As Long
Dim ms As String
mv = "a" 'value to lookup
mc = 1 'col A
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row
If Cells(i, mc) = mv Then ms = ms & Cells(i, mc + 1) & Chr(10)
Next i
MsgBox ms
Cells(1, mc + 2) = ms
End Sub


Gord Dibben MS Excel MVP

On Mon, 2 May 2011 08:09:58 -0700 (PDT), Ram wrote:

Hi,
I want to lookup the value for perticular name.For example if we use
vlookup for "a", as =vlookup(A3,A1:B7,2,0) then it will return 2623
for first occurence of "a" but i want to the value for second or third
occurence for a orb as 452 etc