Lookup a Match in an Array that can be in any column of the Array

rehanahmad

New Member
Joined
Jan 12, 2011
Messages
23
Office Version
  1. 2019
  2. 2016
Hi
I am working on an Excel model where I am struggling to find a formula where I want to look for an exact match in a table of array that can be found in any columns out of 42 columns of the array with about 4000 rows. The search criteria I want to lookup can have up to 2 matches. Can someone please help?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
what is you want to return , when you find that match ?
can you give some further examples

do you want to return the COLUMN Header or ROW header or both

something like this

GRID - Lookup Titles from a Value in the GRID.xlsx
ABCDEFGH
1Title ATitle BTitle CCriteria name
2Object ATomPeteDavePhil
3Object BIanMikePhilExpected result
4Object CGaryAndreKevinObject B-Title CINDEX(A2:A4,MIN(IF(B2:D4=F2,ROW(A2:A4)-ROW(A2)+1)))&"-"&INDEX($B$1:$D$1,MIN(IF(B2:D4=F2,COLUMN(B2:D2)-COLUMN(B2)+1)))
5Need Control+Shift+Enter - array formula
6
7Find the Row and Column info based on the cell in the Grid
8
9
10FIND PhilROWObject B= >>INDEX(A2:A4,MIN(IF(B2:D4=F2,ROW(A2:A4)-ROW(A2)+1)))
11
12Find PhilCOLUMNTitle C= >>INDEX($B$1:$D$1,MIN(IF(B2:D4=F2,COLUMN(B2:D2)-COLUMN(B2)+1)))
13
Sheet1
Cell Formulas
RangeFormula
F4F4=INDEX(A2:A4,MIN(IF(B2:D4=F2,ROW(A2:A4)-ROW(A2)+1)))&"-"&INDEX($B$1:$D$1,MIN(IF(B2:D4=F2,COLUMN(B2:D2)-COLUMN(B2)+1)))
F10F10=INDEX(A2:A4,MIN(IF(B2:D4=F2,ROW(A2:A4)-ROW(A2)+1)))
F12F12=INDEX($B$1:$D$1,MIN(IF(B2:D4=F2,COLUMN(B2:D2)-COLUMN(B2)+1)))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by according to that information. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Hi thanks for your prompt reply.
What I got is two sheets, one of them is a table as shown in Table 1.
Other one has got some data (Table 2) where I want to lookup the string in AV to match with any columns from T:AH....... and return me Column B (OA Variable) in Table 1.
A match can have up to 3 values in column B which I want to returns in different columns.
Trust this helps.
Many thanks for your help.
 

Attachments

  • Excel Table 1.png
    Excel Table 1.png
    22.3 KB · Views: 7
  • Excel Table 2.png
    Excel Table 2.png
    16 KB · Views: 8
Upvote 0
Any possibility of addressing the issue that I raised?
 
Upvote 0
Hi I have updated
Thanks
Thanks. See if you can adapt this (with Excel 2019) to your layout/sheet names if it does what you want.

rehanahmad.xlsm
ATUVWXYZAAAB
1OA VariableHdr2Hdr3Hdr4Hdr5Hdr6Hdr7Hdr8Hdr9Hdr10
2AK1Y9I2X8Q4G8A8D8Y5
3BP2U8P8D5I7I7K4W4Y9
4CE2W4O5B8W8Q1E5T4F4
5DG6B2O3A3Y9J5F2Z5K5
Sheet1



rehanahmad.xlsm
ABCD
1Lookup StringResult 1Result 2Result 3
2W4BC 
3A6   
4Y9ABD
5K9   
6J5D  
7O3D  
Sheet2
Cell Formulas
RangeFormula
B2:D7B2=IFERROR(INDEX(FILTERXML("<p><c>"&TEXTJOIN("</c><c>",1,INDEX(Sheet1!$A:$A,IF(Sheet1!$T$2:$AB$5=$A2,ROW(Sheet1!$A$2:$A$5),99))&"")&"</c></p>","//c"),COLUMNS($B:B)),"")


If you want helpers to work with your actual sample data and layout, investigate XL2BB for providing small dummy sample data and expected results.
 
Upvote 0
IFERROR(INDEX(FILTERXML("<p><c>"&TEXTJOIN("</c><c>",1,INDEX(Sheet1!$A:$A,IF(Sheet1!$T$2:$AB$5=$A2,ROW(Sheet1!$A$2:$A$5),99))&"")&"</c></p>","//c"),COLUMNS($B:B)),"")
Hi Many thanks for looking into. I have applied your logic but all cells returning blank. Can i please ask what "<p><c>" represent? and also if this formula will only work with xlsm version?
 
Upvote 0
Hi Many thanks for looking into. I have applied your logic but all cells returning blank.
Sounds like either you have not applied it correctly or else there is something significantly different about your data and my sample data.
If you have XL2BB installed then perhaps you could provide a small set of dummy sample data that we can test with.

Also, if you start a new workbook you could test with my sample data (depending on the outcome of my final point below). Copy my Sheet1 sample data to cell A1 of your Sheet1 by using this button at the top left of my mini-sheet
1653436051782.png

Then repeat with my Sheet2

Can i please ask what "<p><c>" represent?
There is nothing special about them being p and c but they are to ensure that the string being processes by the FILTERXML function is a valid XML string.


also if this formula will only work with xlsm version?
No, the formula does not need to be in an xlsm workbook but it does require Excel 2013 or later (which your profile update shows you have) and a Windows platform, not Mac, (which unfortunately did not get updated in your profile)
.. so helpers always know what Excel version(s) & platform(s) you are using ..
 
Upvote 0
Hi peter, I am working on it,
part of the formula "COLUMNS($B:B))", is it referring to the Column B where the formula is written? i.e. if the formula is written in B2 in your example, it this part "COLUMNS($B:B))" referring to the same column?
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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