Help with Counting Records Using Multiple Criteria

MartinS

Active Member
Joined
Jun 17, 2003
Messages
487
Office Version
  1. 365
Platform
  1. Windows
Can't think how to do this this morning!
I have some data (wedding guests) in a spreadsheet, and we are working out costings for food/travel etc, so have multiple columns. The first column is name(s), i.e.
Fred & Barbara
Jon & Rob
Sarah
Betty & Barnie
Gabbi
I wanted to count the number of guests, so used the following formula:
Excel Formula:
=(COUNTA(B4:B9)-COUNTIF(B4:B9,"*&*"))+COUNTIF(B4:B9,D11)*2
So, for the selection above, returns 8.
What I also need is to count the number of guests with 'Yes' in another column, and that's where I'm struggling!
Fred & Barbara Yes
Jon & Rob No
Sarah Yes
Betty & Barnie Yes
Gabbi No
So my formula wants to know how many guests have said yes - in the example above, it should return 5.
The formula needs to count each row that has 'Yes' in column 2, and then for each 'Yes' row, the number of guests.
Hope that makes sense?
Thanks
Martin
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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 also suggest that you investigate XL2BB for providing sample data.

Would you ever have entries like "Tom & Bob & Fred" or "Tom, Bob & Fred"?
 
Upvote 0
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 also suggest that you investigate XL2BB for providing sample data.

Would you ever have entries like "Tom & Bob & Fred" or "Tom, Bob & Fred"?
Hi
Apologies - I have updated my details, and for info, we are running office 365.
And to answer your question, no, as it's a list of wedding guests, so it's either singles or couples.
I did think I could simply add a column that has the number of guests per row, then use a SUMPRODUCT formula, such as:
Excel Formula:
=SUMPRODUCT(--(B4:B9="Yes"),C4:C9)
Where column C has the formula:
Excel Formula:
=1+IF(ISERROR(FIND("&",A4)),0,1)
But am hopeful I don't need the extra column C...
Thanks
Martin
 
Upvote 0
Thanks for updating your profile. (y)

What about this?

21 09 16.xlsm
BCDE
3Yes
4Fred & BarbaraYes5
5Jon & RobNo
6SarahYes
7Betty & BarnieYes
8GabbiNo
Count
Cell Formulas
RangeFormula
E4E4=LET(t,CONCAT(IF(C4:C8="Yes","&"&B4:B8,"")),LEN(t)-LEN(SUBSTITUTE(t,"&","")))
 
Upvote 0
A better way

21 09 16.xlsm
BCDE
3Yes
4Fred & BarbaraYes5
5Jon & RobNo
6SarahYes
7Betty & BarnieYes
8GabbiNo
Count
Cell Formulas
RangeFormula
E4E4=COUNTIF(C4:C8,"Yes")+COUNTIFS(C4:C8,"Yes",B4:B8,"*&*")
 
Upvote 0
Solution
Thanks @Peter_SSs
Oddly, your first formula returns #NAME!, but the second one works perfectly and makes sense!
Thanks again!
Martin
 
Upvote 0
Oddly, your first formula returns #NAME!,
Sounds like you might not have the LET function yet. Perhaps you have some updates to do?

In any case the second formula is better anyway so all is good. :)
 
Upvote 0
Sounds like you might not have the LET function yet. Perhaps you have some updates to do?

In any case the second formula is better anyway so all is good. :)
Our updates are controlled, so I have whatever has been deployed. According to Excel, I have Excel for Office 365 MSO (16.0.12527.21798) 32-bit
But agreed, the second one works perfectly!
Thanks again
 
Upvote 0
Our updates are controlled, so I have whatever has been deployed.
LET is a very handy function so perhaps you could start to agitate a little for some more "deployment"? ?
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

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