CountIf but not if ???

Need~help

New Member
Joined
Jan 24, 2013
Messages
4
Hi, I wrote this to sum # of cells containing numbers or letters. =COUNTIF(E4:E16,"**"). How do I write it to ignore cells with the word "train" in it? Thanks
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
maybe...

=COUNTIF(I11:I13,"<>TRAIN")

Unfortunately, that will count blank cells as well.

If you want to ignore cells with train anywhere in the cell, you could try:
=COUNTA(E4:E16)-COUNTIF(E4:E16,"*train*")

To only ignore cells with exactly "train", use:
=COUNTA(E4:E16)-COUNTIF(E4:E16,"train")
 
Upvote 0
Good point,

Though I assumed the poster wanted to include blanks in the count based on the logic that a blank in the range would not contain train and should be included in the count.

Either way, I appreciate you mentioning it.
 
Upvote 0
Unfortunately, that will count blank cells as well.

If you want to ignore cells with train anywhere in the cell, you could try:
=COUNTA(E4:E16)-COUNTIF(E4:E16,"*train*")

To only ignore cells with exactly "train", use:
=COUNTA(E4:E16)-COUNTIF(E4:E16,"train")



I tried no avail. The first one came back with 4 as an answer for both columns
The second comes back with an error which I can't fix. Correct answers were 7 and 2 for Jan 28 and Feb 18. Below is a shot of the spreadsheet. I am trying to add up the columns to show me # of populated cells without the word "train" anywhere in it. Thanks Tom

21-Jan28-Jan4-Feb11-Feb18-Feb
Fi - D
N - D
N - DN - D
R - D
R - D
V/4400 - D V-train
EX-train
N - DN&V - D V-train
Fi - D
N - D
470120

<colgroup><col style="mso-width-source:userset;mso-width-alt:2759;width:58pt" width="78"> <col style="mso-width-source:userset;mso-width-alt:2673;width:56pt" width="75"> <col style="width:49pt" span="2" width="66"> <col style="mso-width-source:userset;mso-width-alt:2360;width:50pt" width="66"> <col style="width:49pt" width="66"> </colgroup><tbody>
</tbody>
 
Upvote 0
...Correct answers were 7 and 2 for Jan 28 and Feb 18...

Don't you mean 7 & 0 are the correct answers?...I copied/pasted your data into a blank spreadsheet and used =COUNTA(E2:E14)-COUNTIF(E2:E14,"*train*") and it produced the proper results (Left to Right: 4,7,0,0,0,0). Are you possibly using an explicit reference with $'s instead of without?
 
Upvote 0

Forum statistics

Threads
1,221,554
Messages
6,160,472
Members
451,649
Latest member
fahad_ibnfurjan

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