Counting inside Cells

banier1

New Member
Joined
May 22, 2024
Messages
5
Office Version
  1. 2021
Platform
  1. Windows
Hi There (First time post or me - please be kind :-) )
I have a response form, from a menu survey, that I'd like to total (count) the numbers of attendees and what their choices are.
However the form design has led to multiple responses in single cells.
See Below.
Is there a way to count the instances when "Adult" is returned? Including when "Adult n, Adult n" is returned, it is counted as 2
In the end I'd like to categorise by first/second sitting and the column of response.
1716364434729.png


Please help
Kind Regards,
Dan
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Maybe this.
Book1
CDEFGHIJ
1
2
3
48pm - Second SittingAdult 1
56pm - First SittingAdult 1, Adult 2First Sitting7
66pm - First SittingAdult 1Adult 1Second Sitting8
78pm - Second SittingAdult 1, Adult 2Adult 1Total15
88pm - Second SittingAdult 1, Adult 2, Adult 3Adult 1
96pm - First SittingAdult 3Adult 1Adult 2
Sheet2
Cell Formulas
RangeFormula
J5J5=LET(f,FILTER(D4:G9,ISNUMBER(SEARCH(I5,C4:C9))),SUM(IF(f=0,0,LEN(f) - LEN(SUBSTITUTE(f, ",", ""))+1)))
J6J6=LET(f,FILTER(D4:G9,ISNUMBER(SEARCH(I6,C4:C9))),SUM(IF(f=0,0,LEN(f) - LEN(SUBSTITUTE(f, ",", ""))+1)))
J7J7=SUM(IF(D4:G9="",0,LEN(D4:G9) - LEN(SUBSTITUTE(D4:G9, ",", ""))+1))
 
Upvote 0
Solution
or simillar approach but different ..!

Excel Formula:
=LET(x,TEXTJOIN(",",TRUE,D2:G2), IF(x <> "", LEN(x) - LEN(SUBSTITUTE(x,",",""))+1,0))
 
Upvote 0
Maybe this.
Book1
CDEFGHIJ
1
2
3
48pm - Second SittingAdult 1
56pm - First SittingAdult 1, Adult 2First Sitting7
66pm - First SittingAdult 1Adult 1Second Sitting8
78pm - Second SittingAdult 1, Adult 2Adult 1Total15
88pm - Second SittingAdult 1, Adult 2, Adult 3Adult 1
96pm - First SittingAdult 3Adult 1Adult 2
Sheet2
Cell Formulas
RangeFormula
J5J5=LET(f,FILTER(D4:G9,ISNUMBER(SEARCH(I5,C4:C9))),SUM(IF(f=0,0,LEN(f) - LEN(SUBSTITUTE(f, ",", ""))+1)))
J6J6=LET(f,FILTER(D4:G9,ISNUMBER(SEARCH(I6,C4:C9))),SUM(IF(f=0,0,LEN(f) - LEN(SUBSTITUTE(f, ",", ""))+1)))
J7J7=SUM(IF(D4:G9="",0,LEN(D4:G9) - LEN(SUBSTITUTE(D4:G9, ",", ""))+1))

Wow that works really well, thanks. I have changed the ranges, to an per-column arrangement, and separately summing meal choices, but your formula does the job wonderfully. Thank you so much
 
Upvote 0
or simillar approach but different ..!

Excel Formula:
=LET(x,TEXTJOIN(",",TRUE,D2:G2), IF(x <> "", LEN(x) - LEN(SUBSTITUTE(x,",",""))+1,0))
Thanks for helping. TBH I struggled to implement your solution, so used the solution from 'Cubist'. What is 'x' in your formula?
Cheers
Dan
 
Upvote 0
To add to my request, and not sure if I'm committing a cardinal sin on this forum(!), but is it possible to achieve the solution in Google sheets? I would ideally like the solution to be in a Google Sheet as the content is generated within there.
 
Upvote 0
In future please mark the post that contains the solution, rather than your post saying it works. I have changed it for you this time. Thanks

is it possible to achieve the solution in Google sheets?
In future if you want something for Google Sheets, you should make that clear at the start & all such questions should be posted in the General Discussion & Other Applications section of the board.
 
Upvote 0
In future please mark the post that contains the solution, rather than your post saying it works. I have changed it for you this time. Thanks


In future if you want something for Google Sheets, you should make that clear at the start & all such questions should be posted in the General Discussion & Other Applications section of the board.
I did hit the tick button against Cubist 's solution. Thanks.
Thanks also for your suggestion of General Discussion... section. I didn't see that when first looking at the forum.
 
Upvote 0
Thanks for helping. TBH I struggled to implement your solution, so used the solution from 'Cubist'. What is 'x' in your formula?
Cheers
Dan
x is basically going to hold the "TextJoin" bit - so x = each cell in the row, joined together in 1 text string. You don't need to change that. From that text string of 1, 2 or 3 "Adult n" seperated by commas, we then remove the "," commas from it, and subtract the length of the new shorter string from the old one stored in x) (which in theory should be 1, 2 or 3 or n characters shorter). If there is 1 comma, you must have 2 Adults .. so we add "1" to each result to get you the answer ... If the string is empty ie. no Adults, we put a 0

all you had to do was amend the D2:G2 to suit the columns you were using, and copy the formula down your rows ...

Anyway - you have your solution - so all good.

cheers
Rob
 
Upvote 1

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

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