Sum values associated with keywords inside cell

witchcraftz

New Member
Joined
Jan 17, 2008
Messages
39
I have a spreadsheet in which I need to do something unusual.

The setup:
Each cell will contain a list of keywords. Each keyword is worth a specific value (1-4). A cell may contain any number of keywords in any order, however each keyword only repeats once.

Data sheet
sourcevalue
Bob1
Mary3
Phil2
Brown4

Results sheet
inputvalue listvalue sum
Phil,Bob,Brown1, 2, 47


Part1 :Getting a list that transposes the words in the cell to a list of associated values.

I've done this 2 ways but I feel both are ugly and nonuser friendly, would be great if someone had a better/simpler way to do this.

In the results sheet I expect the value list to return 1, 2, 4 (in any order is fine)

These work but are ugly:

Option1: =TEXTJOIN(", ", TRUE, IF(COUNTIF(results!A2, "*"&data!A2:A5&"*"), data!B2:B5, ""))

Option2: =IF(ISNUMBER(FIND("Bob",results!A2,1))=TRUE,"1, ","")&IF(ISNUMBER(FIND("Mary",results!A2,1))=TRUE,"3, ","")&IF(ISNUMBER(FIND("Phil",results!A2,1))=TRUE,"2, ","")&IF(ISNUMBER(FIND("Brown",results!A2,1))=TRUE,"4, ","")


Part2 : Sum up the associated values for every word in the cell.

I've looked at sumifs and sumproduct but I couldn't get this to work! :(

The uploaded image shows what the result should be
 

Attachments

  • testfind.jpg
    testfind.jpg
    71 KB · Views: 16
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
These work but are ugly:
I would say that your desired output is far less attractive than your attempt at resolving it. Excel is not meant to work with a list of items in a single cell, if that is what you want then it is simply a case of finding something that works. Option 1 is the best you're going to get for the value list. For the sum you could try
Excel Formula:
=SUMPRODUCT(--ISNUMBER(SEARCH(Data!A2:A5,A2)),Data!B2:B5)
 
Upvote 0
Solution
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

I assume that you are aware that the formulas are not actually checking for keywords, but key strings so that you may get a sum even if none of the key words are present?

21 11 16.xlsm
ABCDEF
1SourceValueInputValue listValue Sum
2Bob1Rosemary,Macphillamy,Nabob,Brownlee1, 2, 3, 410
3Mary2
4Phil3
5Brown4
Sample
Cell Formulas
RangeFormula
E2E2=TEXTJOIN(", ", TRUE, IF(COUNTIF(D2, "*"&A2:A5&"*"), B2:B5, ""))
F2F2=SUMPRODUCT(--ISNUMBER(SEARCH(A2:A5,D2)),B2:B5)
 
Upvote 0
Thanks for the help!

In answer to the keystrings, yes, I am aware however it's good of you to let others know if they try to use the same solution.
This data has been sanitized to avoid disclosing important info. In the actual data each one is very unique. :)
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top