简体   繁体   中英

Sum values besides variable size merged cells

I have a spreadsheet with the following structure: There are entities with unique id -s. Each entity has one or more components . The components have multiple number fields . My task is to calculate the sum of the components number fields for each entity using only basic excel feautres (No VBA, no external scripting).

The problem is with the input format. Here is a little sketch of the problem and with the expected result. Every entity are represented as multiple rows in the spreadsheet. The ID and SUM fields are merged for an entity, individual rows represent components, number fields are never merged (although sometimes they are just empty). There are 4000 such rows, the structure should not be changed (people using the sheet are used to it, and looks good in printing), the sum fields are initially merged but empty. (I think somebody assembled the sheet by hand long ago).

在此处输入图片说明

My thought was to use SUMIF in a formula, but I couldn't access the ID field for the individual rows (components) after the first one in each entity. Looks like excel handles merged cells like the upper-left corner is the cell itself, and all the others are empty. The other problem I ran into is that I cannot apply a formula for the whole SUM column. I tried to select the first cell and drag the little dot in the bottom-right corner, but it refused to do so because the merged cells are of diffrent sizes.

Any idea how could I calculate the SUM field using basic excel and formulas, without VBA and without entering a formula for all the 4000 rows by hand?

Use a helper column (see screenshot). Then use SUMIF

You can hide the helper column.

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