Ask Your Question

# Revision history [back]

### Calc: Sum cells to the right of green cells

I have a Calc spreadsheet, where I have columns of budget category labels and columns of budget numbers. I color categories green when it's something I want to pay for in cash, and so I'd like to get an automatic tally of how much cash I need to withdraw when the month begins.

I'm new to this O&A so I can't upload a screenshot, so here's a trivial example:

---------------------------
| Aaaa* | 10 | Eeee  |  1 |
---------------------------
| Bbbb  | 20 | Ffff* | 15 |
---------------------------
| Cccc* | 50 |       |    |
---------------------------
| Dddd  | 25 |       |    |
---------------------------


(Imagine that the starred cells have a specific foreground color - in my case "Green 4" but I'm still learning Calc and haven't yet found the RGB/Hex for this).

What I'd like to do is get a SUM() for all cells to the right of a green cell. In this trivialized example, that would equal 75. As in this example, not all of the cells will be in the same column, but they will all be in the same worksheet, and the number will always be in the cell directly to the right of the label.

How can I do this? I think this may be too complex for a normal Formula because of the scope and context sensitivity.