Fetching 2nd, 3rd, 4th (and so on) Match while Ignoring Blanks

LearnExcl

Board Regular
Joined
Mar 17, 2010
Messages
245
Office Version
  1. 2016
Platform
  1. Windows
Hi,
The below formula currently fetches the 2nd value, but it is actually the first corresponding in a cell where there is actually a value, since the first corresponding match is a blank cell. Could we revise the formula to fetch the second real value (text) ignoring all the corresponding blank cells?

Excel Formula:
=IF(SUMPRODUCT(--(INDEX($A$2:$AU$500,,MATCH("Nr",$A$1:$AU$1,0))=RIGHT(INDEX($A$1:$CU$500,ROW($A2:B2),MATCH("UMR",$A$1:$CU$1,0)),9))))>=1,IFERROR(INDEX($AM$1:$AM$500,SMALL(IF($J$1:$J$500=RIGHT(INDEX($A$1:$CU$500,ROW($A2:B2),MATCH("UMR",$A$1:$CU$1,0)),9),ROW($AM$1:$AM$500),1000000),2)),""))
 
Last edited by a moderator:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Could you provide an XL2BB data sample with an explanation of what is needed so that we don't have to try and reverse engineer the entire formula?
 
Upvote 0
I suggest that you also update your Account details (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 version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Sheet 1Sheet 2
ABCAB
345​
888​
888​
345​
Gear
980​
455​
Hellen
323​
345​
455​
888​
Heim
980​
Rerer
888​
323​
Steph
345​
Manol
888​
Watson

I suggest that you also update your Account details (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 version. (Don’t forget to scroll down & ‘Save’)
Hi Again,
**I am sorry I am unable to download XL2BB
To make it simple, I just wanted reflect a sample of the data. Sheet1 , B2 is where the 1st formula goes and is carried down. The formula finds the first match for A2 in Column A of Sheet2 to and brings its corresponding value in Column B in Sheet2, while ignoring blanks. The second formula goes on Sheet1, C2 and fetches the second match for A2 in Sheet1 in Sheet2 (same logic), while ignoring blanks. The third formula goes in Sheet 1, D2 and fetches the third match for A2 while ignoring blanks, and son on.
 
Upvote 0
I think I'm following what you need, I've done this in one sheet for simplicity, hopefully it will make sense.
Book1 (version 1).xlsb
ABCDE
1Sheet 1Sheet 2
2ABCAB
3345Gear888
4888Heim345Gear
5980Rerer455Hellen
6323Steph345
7455Hellen888Heim
8980Rerer
9888
10323Steph
11345Manol
12888Watson
Sheet8
Cell Formulas
RangeFormula
B3:B7B3=IFERROR(INDEX(E:E,AGGREGATE(15,6,ROW($E$3:$E$12)/($D$3:$D$12=A3)/($E$3:$E$12<>""),COUNTIF(A$3:A3,A3))),"")
 
Upvote 0
Try in B2 of Sheet1 and copy across and down
Excel Formula:
=IFERROR(INDEX(Sheet2!$B:$B,AGGREGATE(15,6,ROW(Sheet2!$B$1:$B$20)/((Sheet2!$A$1:$A$20=$A2)*(Sheet2!$B$1:$B$20<>"")),COLUMNS($B:B))),"")
 
Upvote 0
Solution
Well spotted, Peter!

I missed the part about dragging right and read it as duplicates dragging down :oops:
 
Upvote 0
Try in B2 of Sheet1 and copy across and down
Excel Formula:
=IFERROR(INDEX(Sheet2!$B:$B,AGGREGATE(15,6,ROW(Sheet2!$B$1:$B$20)/((Sheet2!$A$1:$A$20=$A2)*(Sheet2!$B$1:$B$20<>"")),COLUMNS($B:B))),"")
Fantastic! Thank you so much. I'd be obliged if you could briefly explain the formula and how it works.
 
Upvote 0
An additional question. Can this formula be revised to include multiple ranges? For instance, if I have data in Sheet3 and Sheet4, same columns?
Revised question: Sheet1 , B2 is where the 1st formula goes and is carried down. The formula finds the first match for A2 in Sheet2, Sheet3 and Sheet4 and brings its corresponding value in Column B in Sheet2, while ignoring blanks. The second formula goes in C2 on Sheet1, and fetches the second match for A2 in Sheet2, Sheet3, and Sheet4 (same logic), while ignoring blanks. The third formula goes in D2 of Sheet1 and fetches the third match for A2 in Sheet2, Sheet3, and Sheet4 while ignoring blanks, and so on. I truly appreciate your response.
 
Upvote 0
Is it actually 3 sheets of data being pulled into one, or in reality will it be more?

It could be done by repeating the existing formula in place of the double quotes at the end then changing the sheet number in the repeated section, then adding countif to the column count at the end.

With 2 or 3 sheets it would be just about manageable but any more would result in a very long and messy formula. I can't see that there is any realistic way to condense multiple sheet references into an array with what you're trying to do. I'll hold back on re-writing the formula until you confirm the actual sheet count (and to see if Peter has any alternative ideas).
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,616
Members
449,238
Latest member
wcbyers

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