如何在Excel中获取自动筛选后的记录数
时间:2023-03-10 05:03:49
当我们在Excel中进行自动筛选后,有时需要知道筛选后所保留的行(记录)数。可以用下面的几种方法:
1.直接在任务栏中查看:
当进行自动筛选后,Excel任务栏的左下角可以看到类似下图所示的提示:
还可以选择筛选区域中的某一列,选择时不包括标题行,可以在任务栏的右边看到类似“计数=2”的字样。要在任务栏中显示计数数量,先必需鼠标右击任务栏,在弹出的快捷菜单中选择“计数”。
2.使用SUBTOTAL函数:
假如要在A1:A50区域中进行筛选,第一行为标题行,可以用下面的公式获取筛选后的记录数:
=SUBTOTAL(3,A2:A50)
其中第一个参数3指定用COUNTA函数进行分类汇总。
3.使用VBA代码:
还可以用VBA代码来获取筛选后的记录数,代码如下:
Sub Filter_Return()
Selection.CurrentRegion.Select
'确定选择区域中除标题外的总行数
TotalRows = Selection.Rows.Count - 1
DispRows = 0
HideRows = 0
While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
If ActiveCell.RowHeight = 0 Then
HideRows = HideRows + 1
Else
DispRows = DispRows + 1
End If
Wend
If TotalRows = HideRows Then
MsgBox "未找到任何记录"
Else
MsgBox "所选择的区域有" & DispRows - 1 & "条记录"
End If
End Sub
使用方法是,选择筛选区域中的某个单元格,然后运行代码,Excel会在消息框中给出筛选后的记录数,注意该记录数不包括标题行。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
怎样让PPT让百分比图表[动]起来 图表随数据改变的方法
![](https://img.aspxhome.com/file/2023/10/a350048_0s.jpg)
Win7使用iTools备份SHSH的方法和步骤
![](https://img.aspxhome.com/file/2023/27/a231820_0s.jpg)
Windows中更改hosts文件 屏蔽害人网站
![](https://img.aspxhome.com/file/2023/7/a326806_0s.jpg)
U盘格式化四种常见问题解决汇总
![](https://img.aspxhome.com/file/2023/3/a297478_0s.jpg)
显卡bios怎么刷?刷显卡bios的方法
![](https://img.aspxhome.com/file/2023/6/a322169_0s.png)
nero.exe - nero是什么进程 有什么用
天猫福年有福鱼活动怎么玩 玩天猫福年有福鱼活动的方法
![](https://img.aspxhome.com/file/2023/8/a335747_0s.png)
360安全卫士怎么样?360安全卫士好用吗?
![](https://img.aspxhome.com/file/2023/9/a340408_0s.jpg)
如何在wps表格中使用乘法函数
Win11如何开启高对比度的主题?Win11开启高对比度的主题方法
![](https://img.aspxhome.com/file/2023/2/a284255_0s.jpg)
破解win7系统开机密码的小技巧
![](https://img.aspxhome.com/file/2023/5/a316557_0s.png)
win7桌面图标不见了怎么办 win7显示桌面图标方法
![](https://img.aspxhome.com/file/2023/4/a303868_0s.jpg)
电脑内存怎么超频 电脑内存超频的方法以及参数设置教程
![](https://img.aspxhome.com/file/2023/4/a307004_0s.jpg)
WPS 如何在Word里将阿拉伯数字转换成中文数字或序号
![](https://img.aspxhome.com/file/2023/1/a184751_0s.png)
恢复wind8开机按F8进入高级启动模式的方法
![](https://img.aspxhome.com/file/2023/29/a255272_0s.jpg)
日本内存价格失控:DDR4暴涨!
![](https://img.aspxhome.com/file/2023/3/a296806_0s.jpg)
win10账户头像怎么删除_win10账户头像删除的方法
![](https://img.aspxhome.com/file/2023/2/a285850_0s.jpg)
微软的OneNote是干什么用的?OneNote Mac版软件介绍
![](https://img.aspxhome.com/file/2023/0/a213700_0s.jpeg)
WPS 如何在word流程图的箭头上写字
![](https://img.aspxhome.com/file/2023/9/a186449_0s.jpg)
QQ浏览器怎么截图_QQ浏览器截图的方法
![](https://img.aspxhome.com/file/2023/5/a315987_0s.jpg)