It should look like this
View attachment 111688
So it adds a running total in column D only if there is a value in column B.
The formula in D2 is:
=IF(ISBLANK($B2),"",SUM($B$2:$B2))
What this does is check if cell B2 is blank. If this condition is true, it returns the value "" which is a blank cell. If this condition is false ie cell B2 is not blank, it returns the sum of all values in the range B2:B2, which is just one cell. As you copy the formula down, the logical test moves to the next row and the range increases accordingly, so D5 for example checks for a blank in B5 and returns the sum of the range B2:B5. The $ signs stop the next value from incrementing as you copy the formula, so for example $B$2 will always refer to B2, but $B2 would become B5 if you copied it to row 5.
Does that make sense?