简体   繁体   中英

*EXCEL* If a range of cells contain *STRING* then extract the sum of decimal numbers from positive cells

I've spent a long time trying to figure this out now and have had no progress so far. So what it is i am trying to do is gather the sum of all decimal numbers found in a range of strings in a tables column, this can be done on an individual basis using the below formula:

=LOOKUP(9.9E+307,--LEFT(MID(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0}, $A2&"1023456789")),999),ROW(INDIRECT("1:999"))))

The reason i do not wish to add a dedicated column to the table is because this is being used in only very specific use cases on a financial tracker where an order has been made with multiple items and a single item has later been refunded, the table will then be updated as shown:

PRE REFUND: Amazon Marketplace // £110

POST REFUND: Amazon Marketplace [R-50.20] // £110

So using the above formula i would be able to pull 50.20 from the string. Now, what i need to have done is something similar to the below, this does not work but i'm unsure as to what formula may help with this:

SUM(SUMIF(AprilActivity[ITEM],"*[R-*",LOOKUP(9.9E+307,--LEFT(MID(AprilActivity[ITEM],MIN(FIND({1,2,3,4,5,6,7,8,9,0}, $AprilActivity[ITEM]&"1023456789")),999),ROW(INDIRECT("1:999"))))))

You have only provided a single example, in which it appears that the number you wish to return is that between two substrings:

  • [R-
  • ]

If that is what you really want, then:

=SUM(--MID(myRange,FIND("[R-",myRange)+3, FIND("]",myRange)-FIND("[R-",myRange)-3))

will add all the numbers in myRange that meet those specifications.

And you can replace myRange with AprilActivity[ITEM] , for example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM