Index Match formula pulling from a longer list with blank row spaces or unwanted data into a shorter list without row spaces

MikeWnbExclWiz

New Member
Joined
May 23, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

Long-time lurker, first-time poster. I'm trying to pull the information highlighted in green from the below columns (columns J-L) into separate consolidated columns that only return the information in green and excludes blank or un-highlighted rows. The highlighting is a conditional formatting that is based on the "Yes/No" data validations in column H. So I'd like the formula to be based on those "Yes/No" user selections.

And to add an additional level of complexity, it would be great if that new consolidated list could be effectively sorted by the data validation in column I, which is the "Controllable/Non-Controllable" selection (i.e. have "Controllable" listed first and then "Non-Controllable" next). Or it might be easier if they're displayed in two separate 3-columned lists (first 3 columns for Controllable and next 3 columns for Non-Controllable)

Also the information in columns J-L change between properties, so they won't always be in the same exact position (i.e. one property may have a lot more expense line items under "Advertising & Promotion"), so the formula needs to be dynamic.

I'm trying as a hard as humanly possible not to use macros/VBA.

I appreciate the communities help! I've been banging my head on my desk for a few days now...

Thanks,
Mike
 

Attachments

  • Screenshot 2024-05-23 120833.png
    Screenshot 2024-05-23 120833.png
    68.2 KB · Views: 11

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.
Welcome to the MrExcel forum!

Maybe something like this?

Book1
HIJKLMNOP
1
2
3
4
5
6Shared Expense (Y/N)Controllable/Non-Controllable
7
8
9OPERATING EXPENSE
10Salary & Related-ResidentialNumberDescAmount
11YesNon-Controllable1a1.008h8
12YesNon-Controllable2b2.009i9
13NoNon-Controllable3c3.0010j10
14YesNon-Controllable4d4.0011k11
15YesNon-Controllable5e5.0013m13
16YesNon-Controllable6f6.0014n14
17YesNon-Controllable7g7.00
18Total1a1
192b2
204d4
21Advertising & Promotion5e5
22YesControllable8h8.006f6
23YesControllable9i9.007g7
24YesControllable10j10.0015o15
25YesControllable11k11.0017q17
26NoControllable12l12.0018r18
27YesControllable13m13.0019s19
28YesControllable14n14.0020t20
29Total21u21
3022v22
31
32Utilities
33YesNon-Controllable15o15.00
34NoNon-Controllable16p16.00
35YesNon-Controllable17q17.00
36YesNon-Controllable18r18.00
37YesNon-Controllable19s19.00
38YesNon-Controllable20t20.00
39YesNon-Controllable21u21.00
40YesNon-Controllable22v22.00
41YesNon-Controllable23w23.00
42Total
Sheet6
Cell Formulas
RangeFormula
N11:P30N11=LET(a,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),t,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),s,SEQUENCE(ROWS(t)),IFS(s<=a,INDEX(t,s,{3,4,5}),s=a+1,{"","",""},1,INDEX(t,s-1,{3,4,5})))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J11:L41Expression=$H11="Yes"textNO


I had it insert a blank row between the "Controllable" and "Non-Controllable" sections. But that can be removed, or we can build 2 tables side by side like you suggested.
 
Upvote 0
Thanks for digging in, Eric. A couple of questions, as I'm having a little trouble following the formula - why have you used "t" and "s" in your formula? I'm assuming "a" is to reference the beginning/top of the array, but not quite sure where "t" and "s" come in.

Thanks in advance
 
Upvote 0
Let me walk you through it a bit. I tweaked the formula a bit to make it more understandable (hopefully!).

Book1
HIJKLMNOP
1
2
3
4
5
6Shared Expense (Y/N)Controllable/Non-Controllable
7
8
9OPERATING EXPENSE
10Salary & Related-ResidentialNumberDescAmount
11YesNon-Controllable1a1.008h8
12YesNon-Controllable2b2.009i9
13NoNon-Controllable3c3.0010j10
14YesNon-Controllable4d4.0011k11
15YesNon-Controllable5e5.0013m13
16YesNon-Controllable6f6.0014n14
17YesNon-Controllable7g7.00
18Total1a1
192b2
204d4
21Advertising & Promotion5e5
22YesControllable8h8.006f6
23YesControllable9i9.007g7
24YesControllable10j10.0015o15
25YesControllable11k11.0017q17
26NoControllable12l12.0018r18
27YesControllable13m13.0019s19
28YesControllable14n14.0020t20
29Total21u21
3022v22
3123w23
32Utilities
33YesNon-Controllable15o15.00
34NoNon-Controllable16p16.00
35YesNon-Controllable17q17.00
36YesNon-Controllable18r18.00
37YesNon-Controllable19s19.00
38YesNon-Controllable20t20.00
39YesNon-Controllable21u21.00
40YesNon-Controllable22v22.00
41YesNon-Controllable23w23.00
42Total
Sheet6
Cell Formulas
RangeFormula
N11:P31N11=LET(NumControl,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),table,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),tblseq,SEQUENCE(ROWS(table)+1),IFS(tblseq<=NumControl,INDEX(table,tblseq,{3,4,5}),tblseq=NumControl+1,{"","",""},1,INDEX(table,tblseq-1,{3,4,5})))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J11:L41Expression=$H11="Yes"textNO


The formula is:

=LET(NumControl,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),table,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),tblseq,SEQUENCE(ROWS(table)+1),IFS(tblseq<=NumControl,INDEX(table,tblseq,{3,4,5}),tblseq=NumControl+1,{"","",""},1,INDEX(table,tblseq-1,{3,4,5})))

LET is a relatively new function that lets you create intermediate results. You can calculate them, then name them, then you can reuse them later in the formula without having to recalculate them. In the original formula I name the intermediate results a, t, and s. Which work, but they're not especially clear as to what they're doing. I renamed them in the new version.

=LET(NumControl,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),table,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),tblseq,SEQUENCE(ROWS(table)+1),IFS(tblseq<=NumControl,INDEX(table,tblseq,{3,4,5}),tblseq=NumControl+1,{"","",""},1,INDEX(table,tblseq-1,{3,4,5})))

So in this section, the blue is a COUNTIFS, that just counts how many rows have a Yes in column H, and "Controllable" in column I. It was named a in the old version, it's named NumControl (for Number of Controllable rows) here.

=LET(NumControl,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),table,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),tblseq,SEQUENCE(ROWS(table)+1),IFS(tblseq<=NumControl,INDEX(table,tblseq,{3,4,5}),tblseq=NumControl+1,{"","",""},1,INDEX(table,tblseq-1,{3,4,5})))

In this section, I filter the H11:l100 section, only keeping rows that have "Yes" in column H. I then sort the table by column 2, which is where the Controllable/Non-Controllable code is, so that the Controllable rows sort to the top. This now creates an internal table, which I named table (it was t).

=LET(NumControl,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),table,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),tblseq,SEQUENCE(ROWS(table)+1),IFS(tblseq<=NumControl,INDEX(table,tblseq,{3,4,5}),tblseq=NumControl+1,{"","",""},1,INDEX(table,tblseq-1,{3,4,5})))

In this section, I create an array with the SEQUENCE function. This array contains the numbers 1, 2, 3, 4, etc. up to the number of rows in the table, plus 1. The extra row is for the space I added between the Controllable and Non-Controllable sections. This I named tblseq (for table sequence), it was just s.

=LET(NumControl,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),table,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),tblseq,SEQUENCE(ROWS(table)+1),IFS(tblseq<=NumControl,INDEX(table,tblseq,{3,4,5}),tblseq=NumControl+1,{"","",""},1,INDEX(table,tblseq-1,{3,4,5})))

Finally, I display each row of the table, based on the tblseq value. If the tblseq value is less than or equal to the number of Controllable rows, it displays out columns 3, 4, and 5. (Red section.) If tblseq is 1 over the number of Controllable rows, it displays 3 spaces. (Blue section.) Otherwise, (the 1 works as a TRUE value here, so if the first 2 sections aren't triggered, the 3rd always will be), the remaining rows of the table are displayed. (Green section.)

Hope this helps!
 
Upvote 0
Wow, super cool. I really appreciate it!

I have another challenge for you, if you choose to accept it...Is there a way to make it so the first row just be a heading saying "Controllable" and then have a row between the blank row and the next set of rows of information be a heading saying "Non-Controllable". And could there be a row inserted at the end of each section summing up the Controllable and Non-Controllable values and "Total" row at the bottom (after another space) that shows a total of the Controllable and Non-Controllable? I don't even know if this is possible, but figure if anyone knows or could figure it out, it would probably be you.
 
Upvote 0
Well, I always like a challenge:

Book1
HIJKLMNOP
1
2
3
4
5
6Shared Expense (Y/N)Controllable/Non-Controllable
7
8
9OPERATING EXPENSE
10Salary & Related-ResidentialAccount NumberDesc Amount
11YesNon-Controllable1a1.00Controllable
12YesNon-Controllable2b2.008h$ 8.00
13NoNon-Controllable3c3.009i$ 9.00
14YesNon-Controllable4d4.0010j$ 10.00
15YesNon-Controllable5e5.0011k$ 11.00
16YesNon-Controllable6f6.0013m$ 13.00
17YesNon-Controllable7g7.0014n$ 14.00
18TotalTotal:$ 65.00
19
20Non-Controllable
21Advertising & Promotion1a$ 1.00
22YesControllable8h8.002b$ 2.00
23YesControllable9i9.004d$ 4.00
24YesControllable10j10.005e$ 5.00
25YesControllable11k11.006f$ 6.00
26NoControllable12l12.007g$ 7.00
27YesControllable13m13.0015o$ 15.00
28YesControllable14n14.0017q$ 17.00
29Total18r$ 18.00
3019s$ 19.00
3120t$ 20.00
32Utilities21u$ 21.00
33YesNon-Controllable15o15.0022v$ 22.00
34NoNon-Controllable16p16.0023w$ 23.00
35YesNon-Controllable17q17.00Total:$ 180.00
36YesNon-Controllable18r18.00Grand Total:$ 245.00
37YesNon-Controllable19s19.00
38YesNon-Controllable20t20.00
39YesNon-Controllable21u21.00
40YesNon-Controllable22v22.00
41YesNon-Controllable23w23.00
42Total
43
Sheet6
Cell Formulas
RangeFormula
N11:P36N11=LET(NumControl,COUNTIFS(H11:H100,"Yes",I11:I100,"Controllable"),SumControl,SUMIFS(L11:L100,H11:H100,"Yes",I11:I100,"Controllable"),SumNonControl,SUMIFS(L11:L100,H11:H100,"Yes",I11:I100,"Non-Controllable"),table,SORT(FILTER(H11:L100,H11:H100="Yes"),2,1),rws,ROWS(table),tblseq,SEQUENCE(rws+6),IFS(tblseq=1,{"Controllable","",""},tblseq<=NumControl+1,INDEX(table,tblseq-1,{3,4,5}),tblseq=NumControl+2,CHOOSE({1,2,3},"Total:","",SumControl),tblseq=NumControl+3,{"","",""},tblseq=NumControl+4,{"Non-Controllable","",""},tblseq<rws+5,INDEX(table,tblseq-4,{3,4,5}),tblseq<rws+6,CHOOSE({1,2,3},"Total:","",SumNonControl),1,CHOOSE({1,2,3},"Grand Total:","",SumControl+SumNonControl)))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
N:NExpression=FIND(" "&N1&" "," Controllable Grand Total: Non-Controllable ")textNO
J11:L41Expression=$H11="Yes"textNO


However, I have a couple suggestions for you. First, I'm limited to Excel 2021 functions. There's a lot of newer functions, like VSTACK or MAP, that might make this simpler. You might post this formula in another thread and see if anyone can simplify it.

Next, look into the Pivot Table functionality. It basically works as a mini report writer, which is what we have here. I noodled around a bit, and got something like this:

1717023348060.png


I'm rusty on these, I'm sure it can be improved. But once you get the hang of it, you can do these much quicker than a complicated formula. There are lots of tutorials on the web.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,152
Members
452,615
Latest member
bogeys2birdies

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