尝试计算要在状态栏上显示的范围内的单元格数量。不确定如何计算用作进度条分母的范围内的单元格数量。有什么想法吗?
For Each cell In Range("E11:G28,E33:G50,E57:G74,E79:G96,E101:G118,E130:G147,E152:G169,E175:G192,E198:G215,E221:G238")
**lTotal = Range.Cells.Count**
Application.StatusBar = "Processing cell " & cell.AddressLocal & _
" " & Format((lCounter / lTotal), "0%")
cell.EntireRow.Hidden = (cell.Value = "")
lCounter = lCounter = 1
Next cell
非常感谢
最佳答案
此版本逐行查看您的范围,而不是逐个单元格
它还会关闭ScreenUpdating
以避免闪烁,重置StatusBar
等
Sub ReCut()
Dim rData As Range
Dim rng1 As Range
Dim rng2 As Range
Dim rcell As Range
Dim lngCnt As Long
Dim lngCalc As Long
Set rData = Range("E11:G28,E33:G50,E57:G74,E79:G96,E101:G118,E130:G147,E152:G169,E175:G192,E198:G215,E221:G238")
For Each rng1 In rData.Areas
ltotal = ltotal + rData.Rows.Count
Next
With Application
.ScreenUpdating = False
.EnableEvents = False
lngCalc = .Calculation
.Calculation = xlCalculationManual
For Each rng2 In rData.Areas
For Each rcell In rng2.Rows
rcell.EntireRow.Hidden = (.CountBlank(rcell) = 3)
lngCnt = lngCnt + 1
.StatusBar = "Processing row " & lngCnt & " " & Format((lngCnt / ltotal), "0%")
Next rcell
Next
.ScreenUpdating = True
.EnableEvents = True
.Calculation = lngCalc
.StatusBar = vbNullString
End With
End Sub
关于excel - VBA计算范围内的单元格数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24117636/