Count the amount of times criteria appears in a cell

aeroguy1

New Member
Joined
Mar 16, 2015
Messages
24
Hello,

How do you count the amount of times criteria (in this case airplane seats i.e. 1A, 11A, 16C, etc.) occur in a single cell. The cell has any number of seats.

I can nest the airplane seats in a list or type it in the formula. I have 30 seats of interest.

Thank you!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Depends on how the data actually turns up in the cell and whether the data entry standard is reliable.

For example, if the data was always < seat number ><seatnumber>,<seatnumber>< seat number >,<seatnumber>< seat number >

...then number of seats is just number of commas +1:

=len(a1)-(len(substitute(a1,",","")))+1

...gets more complex as data gets less structured.

Post back with some real examples if it's not as simple as the above.</seatnumber></seatnumber></seatnumber>
 
Last edited:
Upvote 0
The seats appear in comment fields that are not standard.

“Replaced tray table assy 10A, 11A, 12,D”
“Seat 1A screen INOP”

I have hundreds of these cells and I would like to define seats and then have a function count the criteria in the text field.

Thank you!

Depends on how the data actually turns up in the cell and whether the data entry standard is reliable.

For example, if the data was always <seatnumber>,<seatnumber>,<seatnumber>

...then number of seats is just number of commas +1:

=len(a1)-(len(substitute(a1,",","")))+1

...gets more complex as data gets less structured.

Post back with some real examples if it's not as simple as the above.
 
Upvote 0
Tricky - if there is no standardisation in the data entry, then it is more-or-less impossible to define an algorithm - they need some regular features to work off.

Might be somewhat more tractable using vba / reg expressions but those aren't really my sort of thing...
 
Upvote 0
You could try something like:

ABCDEFG
1MessageCountSeats of interest
2Replace tray table assy 10A, 11A, 12,D210A
3Seat 1A screen INOP010B
4Seats 10A 10B, 10C 12B 12D cleaned510C
510A seat torn, 13B stained, 10C screen INOP211A
6011B
70
8011C
9012A
10012B
11012C
1212D

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet6

Worksheet Formulas
CellFormula
E2=SUMPRODUCT(--ISNUMBER(SEARCH($G$2:$G$31,A2)),--($G$2:$G$31<>""))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



It searches the list in G for matches, and counts them. It won't pick up something like 12,D because it's not in the list. If that kind of thing happens a lot, you could add 12,D to the end of the list. But with non-standard entry, you might have to settle for less than 100% accuracy.
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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