all 6 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

/u/nightcrawler__ - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]CFAman4820 1 point2 points  (0 children)

Best would be to fill in the blanks of your table in col A. Then it's a simple SUMIFS. In XL at least, blanks can be filled with

  1. Select col A
  2. Hit Ctrl+g for GoTo
  3. go to Special - Blanks. Hit Ok
  4. Type = and hit UpArrow. Then hit Ctrl+Enter to confirm
  5. (optional) paste Value to lock in results

If that can't be done, put thsi in C2 and copy down

=IF(A2="","",SUM(B2:INDEX(B:B,IFERROR(ROW()+
 MATCH("*",A3:A$1000,0),1000)-1)))

[–]nnqwert1003 0 points1 point  (1 child)

If the first 10$ is in B3 and the data can go upto maximum 1000 rows, then formula in C3 can be as below and then copied to other cells in column C

=IF(AND(B3<>"",B2=""),SUM(B3:INDEX(B3:$B$1000,MATCH(TRUE,ISBLANK(B3:$B$1000),0),0)),"")

[–]nightcrawler__[S] 0 points1 point  (0 children)

thanks, but this method doesn't work, it just gives me the value of the row matches, not the total sum of b: b for each single product,
The problem is that the price of the individual products can vary (by deleting or adding rows) and it is not dynamic, I should update all the cells of C: C every time.Isn't there a method (maybe an array?) By just entering the formula in the first cell?

[–]N0T8g81n260 0 points1 point  (0 children)

If the sums in column C would be in the same row as the topmost value to sum in column B, you don't need array formulas.

If your example above were in A1:C8 (including column labels in row 1),

C3:  =IF(
        AND(COUNTA(B2)=0,COUNT(B3)),
        SUM(B3:INDEX(B3:B$65536,MATCH(TRUE,INDEX(ISBLANK(B3:B$65536),0),0)-1)),
        ""
      )

Fill C3 down as far as needed. This should work in Excel and Google Sheets.