Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Recursive Lookup in excel

Posted on 2014-03-11
Medium Priority
397 Views
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
Question by:CalmSoul
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 13

Expert Comment

ID: 39921540
pls explain more about "Lookup TABLE", output and type table/sets.
0

LVL 5

Author Comment

ID: 39921552
example attached
0

LVL 13

Expert Comment

ID: 39921553
pls explain the logic
0

LVL 23

Accepted Solution

Ejgil Hedegaard earned 2000 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
End If
End Function

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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
###### Suggested Courses
Course of the Month7 days, 21 hours left to enroll