エクセルで「オートフィルタ」などを使ってデータを絞り込むとき
表示されている部分の数字や文字の個数を数えることができる関数を紹介します。
非表示にしたセルは数えません。

これも実務ではよく使う関数です。
オートフィルタの設定の方法は下の記事を参考にしてください。
1.SUBTOTAL関数で数字の個数を数える
数字の個数を数える関数は「CONUT」関数
文字の個数を数える関数は「COUNTA」関数


G24のセルに入力した式は
=SUBTOTAL(102,G3:G22)
構文はSUBTOTAL(集計方法,範囲1,範囲2,・・・)
数字の個数を数える関数COUNT関数に該当するのが引数102の数字です。
範囲は,コンマで横に付け加えることで複数の列を指定できます。



この102の数字が重要です。
さてここで課を1課と2課だけを選択してみましょう。


G25のセルにはCOUNTA関数が書かれて結果は同じように見えますが
数字の個数を数える時には、COUNT関数を使ってください。


このようにG3のセルに見えない文字「スペース」を入れると
COUNTA関数では、それも数えてしまうからです。
2.SUBTOTAL関数で文字の個数を数える
文字の個数を数える関数「COUNTA」関数の引数は「103」です。


C25のセルに入力した式は
=SUBTOTAL(103,C3:C22)
文字だけの個数を導き出せました。
① 数字の個数を数えるCOUNT関数で表示されているものだけの個数を数えるには
SUBTOTAL(102,範囲1,範囲2,・・・)
② 文字の個数を数えるCOUNTA関数で表示されているものだけの個数を数えるには
SUBTOTAL(103,範囲1,範囲2,・・・)



実務でよく使うのは引数109,102,103です。