Solved

Recursive Lookup in excel

Posted on 2014-03-11
4
269 Views
Last Modified: 2014-03-26
I would like to find all values from the lookup and split them by "OR" if there is more than one .. sample attached
Recursive-Lookup---Sheet1.csv
0
Comment
Question by:CalmSoul
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39921540
pls explain more about "Lookup TABLE", output and type table/sets.
0
 
LVL 5

Author Comment

by:CalmSoul
ID: 39921552
example attached
0
 
LVL 13

Expert Comment

by:Santosh Gupta
ID: 39921553
pls explain the logic
0
 
LVL 21

Accepted Solution

by:
Ejgil Hedegaard earned 500 total points
ID: 39921878
Put this in a VBA module
Option Explicit

Function RecursiveLookup(Id As Range, Table As Range)
    Application.Volatile
    Dim i As Long, arTable As Variant
    arTable = Table
    For i = LBound(arTable, 1) To UBound(arTable, 1)
        If arTable(i, 1) = Id Then
            If Len(RecursiveLookup) = 0 Then
                RecursiveLookup = arTable(i, 2)
            Else
                RecursiveLookup = RecursiveLookup + " OR " + arTable(i, 2)
            End If
        End If
    Next i
    If Len(RecursiveLookup) = 0 Then
        RecursiveLookup = "NOT FOUND***"
    End If
End Function

Open in new window


Address the function like this for cell B2, ID in A2, and table in G2:H13
=RecursiveLookup(A2,$G$2:$H$13)

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now