# Sum up values based on comma separated values that reference a table

#### aperkinsptx

##### New Member
Hi, I'm new to posting on forums like this so bare with me as I try to explain what I'm attempting to accomplish.

My company has a lab and we run different tests for different samples. I'm trying to find the total time the sample will take to run based on the tests selected. We currently have lists of tests to run listed in a single cell as comma separated values. I have a separate sheet where I have listed each of those tests and the average time for each test to be run. I'd like to return the sum.

Below is how I would do it manually. The formula would be in the "Total Sample Time" column.

 Tests to Run Total Sample Time Test 1, Test 2, Test 3 = 5+10+12=27 Test 3, Test 4 =12+1=13 Test 1, Test 3, Test 4 , Test 5 =5+12+1+15=33

<colgroup><col><col></colgroup><tbody>
</tbody>

 Test Type Time (min) Test 1 5 Test 2 10 Test 3 12 Test 4 1 Test 5 15

<colgroup><col><col></colgroup><tbody>
</tbody>

I'm just not sure what type of formula needs to be in the cell to be able to sum up the values from a table based on the comma separated values.

#### Domenic

##### MrExcel MVP
Assuming that A1:B11 contains the table, try...

B2, confirmed with CONTROL+SHIFT+ENTER, and copied down:

=SUM(IF(ISNUMBER(SEARCH(","&\$A\$7:\$A\$11&",",","&SUBSTITUTE(SUBSTITUTE(TRIM(A2)," ,",","),", ",",")&",")),\$B\$7:\$B\$11))

Note that the formula allows extra spaces within the text string, such as the text string in A4. Also, note that the SEARCH function is not case-sensitive. For a case-sensitive formula, replace SEARCH with FIND.

Hope this helps!

#### aperkinsptx

##### New Member
Thanks so much Domenic, your answer worked perfectly!

#### Domenic

##### MrExcel MVP
You're very welcome! Thanks for the feedback!

1,081,990
Messages
5,362,584
Members
400,683
Latest member
LogChief

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...