过程开始执行前关闭屏幕刷新,还能提高速度:
Application.ScreenUpdating = False
结束后,恢复,一下子只看到最终结果。
Application.ScreenUpdating = True
头里加上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