Multi-lookup formula

jwpickett

New Member
Joined
Jan 19, 2005
Messages
36
I have a situation where I cannot find a good formula to use when I need to return multiple values from an array. It works fine for single values. I'm having to concatenate values to get the desired results. Let me explain.

record A B C D E F G H I J DESIRED RESULT
1 1 A
2 1 B
3 1 C
4 1 D
5 1 E
6 1 1 1 F,G,H
7 1 1 H,J
8 1 G,I
9 1 1 1 1 1 G.H.I.J,K
10 1 1 1 F,I,J


Where columns headed A-D can only have one selection and E-J can have multiple selections. I've tried the LOOKUP function which works where there is only one selection. When applied to record 6, for example, it only returns the first instance of finding the "1", which is column E, ignoring the info in G, H and I.

anyone????

thanks
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
sda14 data.xls
ABCDEFGHIJKL
1recordABCDEFGHIJDESIREDRESULT
211A
321B
431C
541D
651E
76111F,G,H
8711H,J
981G,I
10911111G.H.I.J,K
1110111F,I,J
12
13WherecolumnsheadedA-EcanonlyhaveoneselectionandF-Jcanhavemultiple.
Sheet2
 
Upvote 0
Some one smarter than me may know a standard function , but my solution would be to create a UDF

Code:
Function MLookup(rng As Range, row As Long)

' row is the row number of the values to return are

Dim cell As Range, st As String

   Application.Volatile
   st = ""

For Each cell In rng
   If cell.Value<> "" Then
      st = st & Cells(row, cell.Column).Value & ","
   End If
Next cell
     
MLookup = st

End Function
Book1
ABCDEFGHI
1Recordabcdefg
2133a,b,
32333322a,b,c,d,g,
43333333a,d,e,f,g,
5433a,b,
653b,
7633446b,c,d,f,
87455666d,e,f,g,
Sheet1
 
Upvote 0
Control+shift+enter, not just enter...

=SUBSTITUTE(MCONCAT(IF(B2:K2,","&$B$1:$K$1,"")),",","",1)

...and copy down.

MCONCAT requires the free morefunc.xll add-in.

ACONCAT of which you can easiy find the code in VBA here does the same as MCONCAT.
 
Upvote 0

Forum statistics

Threads
1,215,284
Messages
6,124,067
Members
449,140
Latest member
SheetalDixit

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top