Couldn't come up with a 'Clean' solution, that is one formula that could be entered in J4 and copied down and across to M8. This proposed solution has three parts actually, column J is populated by using the array entered formula:
Formula:
=IFERROR(INDEX(Accounts!N$4:N$14,SMALL(IFERROR(ROW(A$1:A$14)/((Accounts!$S$4:$S$14=$A4)*(Accounts!N$4:N$14<>"")),FALSE),2)),IFERROR(INDEX(Accounts!O$4:O$14,SMALL(IFERROR(ROW(A$1:A$14)/((Accounts!$S$4:$S$14=$A4)*(Accounts!O$4:O$14<>"")),FALSE),1)),""))
Columns K and L are populated using the array entered formula:
Formula:
=IFERROR(INDEX(Accounts!O$4:O$14,SMALL(IFERROR(ROW(B$1:B$14)/((Accounts!$S$4:$S$14=$A4)*(Accounts!O$4:O$14<>"")),FALSE),1)),IFERROR(INDEX(Accounts!P$4:P$14,SMALL(IFERROR(ROW(B$1:B$14)/((Accounts!$S$4:$S$14=$A4)*(Accounts!P$4:P$14<>"")),FALSE),1)),""))
Column M is populated using the array entered formula:
Formula:
=IFERROR(INDEX(Accounts!Q$4:Q$14,SMALL(IFERROR(ROW(D$1:D$14)/((Accounts!$S$4:$S$14=$A4)*(Accounts!Q$4:Q$14<>"")),FALSE),1)),"")
*Array entered formulas are activated by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
Another thing that I should mention is that the formulas don't block duplicates (K4 and M8) so a conditional formatting rule is applied to the range J4:M8 which matches the font to the fill, in this case yellow, and hides the duplicates using the formula:
Formula:
=COUNTIFS($I4:I4,J4)>0
Let us know if you have any questions.
Bookmarks