|
補足。
MsgBox ActiveSheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1
#...でも良いとは思いますが、SpecialCellsは不連続範囲数約8,000くらいまでという制限あるそうです。
#しかもなんか遅いし。
Sub test()
MsgBox afCount(ActiveSheet)
End Sub
Function afCount(ws As Worksheet)
Dim r As Range
Dim ret
On Error GoTo errH
Set r = ws.AutoFilter.Range
Set r = r.SpecialCells(xlCellTypeVisible)
ret = CLng(r.Count) - 1
Set r = Nothing
errH:
If Err.Number <> 0 Then ret = Err.Number & ":" & Err.Description
Set r = Nothing
afCount = ret
End Function
|
|