excel vba 请问执行这段代码如何让它不闪烁?

2024-12-01 22:13:24
推荐回答(2个)
回答1:

过程开始执行前关闭屏幕刷新,还能提高速度:

Application.ScreenUpdating = False

结束后,恢复,一下子只看到最终结果。

Application.ScreenUpdating = True

回答2:

头里加上Application.ScreenUpdating = False,末尾加上Application.ScreenUpdating = True
Private Sub CommandButton1_Click()
Dim i As Integer
Application.ScreenUpdating = False
For i = 2 To 26
If Sheets(i).Visible = True Then
Sheets(i).Visible = False
ElseIf Sheets(i).Visible = False Then
Sheets(i).Visible = True
End If
Next i
Application.ScreenUpdating = False
End Sub