简体   繁体   中英

Excel formula (no VBA) - Select from specified cell to next blank in column

I have a worksheet that contains two separate charts:

Name Year 1 Count Year 1 Dollars Year 2 Count Year 2 Dollars ...
Bob ... ... ... ... ...
Anna ... ... ... ... ...
etc. ... ... ... ... ...
Name Year 1 Subcount 1 Year 1 Subcount 2 Year 1 Subcount 3 Year 1 Dollars Year 2 Subcount 1 Year 2 Subcount 2 Year 2 Subcount 3 Year 2 Dollars ...
Bob ... ... ... ... ... ... ... ... ...
Anna ... ... ... ... ... ... ... ... ...
etc. ... ... ... ... ... ... ... ... ...

For the second chart, I'd like to grab the dollar amounts from the first chart instead of recalculating. It's easy enough to do with something along the lines of =INDEX(C$2:C$10,MATCH($A7,$A$2:$A$10,0)) (this would be in Year 1 Dollars for Bob in the second chart, ie cell E7). The problem is that more names are likely to be added to the charts over time, which means that hardcoding the ranges in such a manner will eventually cause problems. So instead, I'd like to take advantage of the blank row in between the two charts (ie row 5) and use a formula along the lines of =INDEX(C$2:[next blank cell in C],MATCH($A7,$A$2:[next blank cell in A],0)) . Normally I could accomplish this with C2:INDEX(C:C,COUNTA(C:C)) , but that doesn't work in this case because there is more data below the first chart. I realize that this could easily be solves by putting the second chart to the right of the first instead of below it, or by transposing each chart, but I'm not sure I can convince the end user to accept that. Any ideas?

you could use tables. To expand, mark the empty row and insert a sheet row, then expand the upper table by dragging or adding data.

在此处输入图像描述

Formula you gave I would recommend to change. For example to this one:

=INDEX($C$2:$C$5;MATCH($A8;$A$2:$A$5;0))

Witout table you could do like this:

在此处输入图像描述

=INDEX($E$2:$E$5;MATCH($A7;$A$2:$A$5;0);0)

Inserting a row, will update the formulas as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM