缺少 Application.ScreenUpdating = True

功能建议 · 163 次浏览
CL 创建于 2023-09-10 17:02

锁定屏幕刷新,后面没有恢复,执行完脚本后Excel反应不太正常,修正后的代码:

Sub DeleteEmptyRows()
Dim LastRow As Long, r As Long
LastRow = ActiveSheet.UsedRange.Rows.Count
LastRow = LastRow + ActiveSheet.UsedRange.Row - 1
Application.ScreenUpdating = False
For r = LastRow To 1 Step -1
If WorksheetFunction.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
Application.ScreenUpdating = True
End Sub

 


回复内容
暂无回复
回复主贴