0
I have a set of rows like this that display some hierarchical data.
A | B | C | D | E | F
1 Task | | 1 | | 2 |
2 Task | | 1 | | 2 |
3 Task | | | | 8 |
4 | Subtask | | 2 | | 4
5 | Subtask | | 2 | | 4
6 Task | | 1 | | 2 |
7 Task | | 1 | | 2 |
Columns A and B are tasks and subtasks, columns C and D are inputs corresponding to each task/subtask. Columns E and F are transformations columns C & D (here they're simply doubled).
Notice that C3 is empty, because the task is not given a value directly; rather it is the sum of the subtasks. Correspondingly, E3 is =SUM(F4:F5).
Currently I do this manually. I would like a function that would do something like the following pseudocode:
IF(
NOT(C3=""),
C3,
SUM_UNTIL(E:E,NOT(""),F:F)
)
So the cell E3 would:
- use the value in C3 if C3 is not blank.
- If C3 is blank, SUM() the cells in F4:F for any number of contiguous blank cells in C.
I am pretty good to very good in excel. Also, I am a programmer, but I don't know VB at all (linux guy), so I'd be happy with a VB solution. I am fluent in JavaScript so that would work too if there's some sort of javascript plugin for excel).
I'm using the latest version of Excel (maybe 2016? The one in the latest business edition of office).
Thanks! This worked very well. For anyone else finding it useful: The big trick to remember is that the INDIRECT("F"&ROW()+1":F"... portion will not drag horizontally (the "F" has to be modified manually each time you change rows). – Sir Robert – 2017-04-29T13:04:40.770