Count a number if a set word/words is in a cell

Paul365

New Member
Joined
Oct 29, 2021
Messages
23
Office Version
  1. 2016
Platform
  1. Windows
  2. Mobile
Hello,

I am trying to create a easy formula which can count hours for staff on a schedule automatically, however some names are going to be in the same cell.

Example:

A B C D E F
A1 Start Time Finish Time Hours Venue Staff Name Hours Worked
A2 8:00 am 10:00 am 2 Paul, Taylor Paul 4
A3 12:00 pm 2:00 pm 2 Paul Taylor 2
 

Attachments

  • Scheudle Help.JPG
    Scheudle Help.JPG
    33 KB · Views: 7
Take 1 below is the simplest way to do this, but there is a risk of incorrect results if one name can be found in another, e.g. Pam in Pamela, or John in John-Paul.

Take 2 is safer, and relies on wrapping each name in a special character - people often use "|" here, so that there is a difference between |Pam| and |Pamela|.

I've used Char(10) on the assumption that your data is using Char(10) to separate multiple names in the same cell?

ABCD
1AmountPersonPerson
25Taylor PaulPamela Paul
37TaylorPamela
411Bob TaylorPam Pamela
5
6Take 1
7Paul5Paul5
8Taylor23Pam23
9Bob11Pamela23
10
11Take 2
12Paul5Paul5
13Taylor23Pam11
14Bob11Pamela23
Sheet1
Cell Formulas
RangeFormula
B7:B9,B12:B14,D7:D9B7=SUMPRODUCT($A$2:$A$4,--ISNUMBER(SEARCH(A7,B$2:B$4)))
D12:D14D12=SUMPRODUCT($A$2:$A$4,--ISNUMBER(SEARCH(CHAR(10)&C12&CHAR(10),CHAR(10)&D$2:D$4&CHAR(10))))
 
Upvote 0

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