Home > Software engineering >  Sum several values between brackets separated by line break in Excel
Sum several values between brackets separated by line break in Excel

Time:12-11

I would like to sum several values between brackets that are separated by line breaks in the same cell, where there are other characters.

I have tried the suggested formula enter image description here

So in this case, the sum wanted is 1 2 2 3 1 3

Thank you,

Najoua

CodePudding user response:

Try:

enter image description here

Formula in A3:

=SUM(--INDEX(TEXTSPLIT(A1,{"(",")"},CHAR(10)),,2))

Or, for Excel 2013 (and higher):

=SUMPRODUCT(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"(",")"),CHAR(10),")"),")","</s><s>")&"</s></t>","//s[position() mod 3 = 2]"))
  • Related