
VBAから
・オートフィルタの設定
・絞り込み(数値)
・絞り込んだ結果の件数を取得
する方法を記載します!
前提
シート「sample」の以下の表に対して、
・オートフィルタの設定
・絞り込み(数値)
・絞り込んだ結果の件数を取得
します。

VBAコード
ここでは例として、
・オートフィルタの設定と表の2列目「売上」を
・「1000以上~3000以下」で絞り込み
・絞り込んだ結果の件数を取得
します。
Option Explicit
Sub sample()
Dim total As Long
'オートフィルタの設定と表の2列目「売上」を「1000以上~3000以下」で絞り込み
Worksheets("sample").Range("B2").AutoFilter field:=2, _
Criteria1:=">1000", _
Operator:=xlAnd, _
Criteria2:="<=3000"
'絞り込んだ結果件数を取得
total = WorksheetFunction.Subtotal(3, Worksheets("sample").Columns("C")) - 1
MsgBox "絞り込んだ結果の件数は『" & total & "』件です。"
End Sub
実行結果
以下ができました。
・オートフィルタの設定
・絞り込み(数値)
・絞り込んだ結果の件数を取得
