What's the problem exactly? Is it a matter of referencing the adjacent cells, or of **conditionally** calculating the values? Regarding relative references, see Eugene's reply. To conditionally insert content, you could combine the IF function together with the CONCATENATE function:

`=IF(CONCATENATE(B1;C1) <> "";1;"")`

Concatenating results to a string if one of the concatenated cells contain a value.

If the content to insert depends on the row above, you will either have to start the table in the second row, or use a different function from the second row on:

`=IF(CONCATENATE(B2;C2) <> "";SUM(A1;1);"")`

Next point is what to do if, for example, the eigth row has no values in B8:C8. Just augmenting the above cell's value in A9 will start again from 1:

If you want to continue counting, you will have to count the cells above from the current one that aren't empty or 0. There's a COUNTIF function that does exactly that. So, your function may look like (again starting from row 2):

`=IF(CONCATENATE(B2;C2) <> "";SUM(COUNTIF($A$1:A1;">0");1);"")`

or, split up on different lines and with comments:

```
=IF(
CONCATENATE(B2;C2) <> ""; # Condition to check
SUM( # output if condition matches
COUNTIF($A$1:A1;">0");# count cells from $A$1 to cell above if not 0
1 # augment value by 1
);
"" # output if condition doesn't match
)
```

This is the function for the second row; just copy the cell to the next rows. It should give the following result: