VBA使用activex复选框隐藏和取消隐藏行

时间:2015-06-23 13:25:56

标签: excel vba excel-vba hide rows

有人可以帮助我提高效率吗?它运行大约10秒钟。非常感谢!

我已修改此代码以隐藏包含“隐藏”的行,这是我工作表A列中公式的结果。

Sub Hide_Rows()

 Application.Calculation = xlCalculationAutomatic
 Application.ScreenUpdating = False
 With ActiveSheet
For Each cell In .Range("a7:a115")
 If cell.Value = "Hide" Then
 cell.EntireRow.Hidden = True
 End If
 Next
 End With
 Application.ScreenUpdating = True
 End Sub

我有一个类似的Show_Rows子,用于取消隐藏的行。我已将按钮结果(True或False)链接到单元格A1,然后我在复选框VBA中使用If语句到Hide_Rows或Show_Rows

Private Sub CheckBox1_Click()
If Cells(1, 1).Value = True Then
     Hide_Rows
 Else
    Show_Rows
End If
End Sub

1 个答案:

答案 0 :(得分:1)

大卫泽门斯说,你的问题可能与许多复杂的公式有关。您对Application.Calculation有正确的想法,但它应该在开始时为Application.Calculation = xlCalculationManual,然后在结尾时为Application.Calculation = xlCalculationAutomatic

相关问题