Solved

Recursive Lookup in excel

Posted on 2014-03-11
4
289 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

772 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