我正在尝试在单元格K1中使用启动和停止按钮在Excel中创建一个秒表,即使其他单元格在工作表上更新也会继续运行 .

我在工作表的VBA窗口中尝试下面的代码,但是我一直收到一条错误消息“无法运行宏'UpdateTime' . 宏可能在此工作簿中不可用,或者所有宏都可能被禁用 . ”我很肯定宏已启用,文件保存为.xlsm . 我应该如何更新代码才能使其正常工作?

Sub UpdateTime()

Range("K1").Value = Now - gdtStart
DoEvents

If Not gbStop Then
    Application.OnTime Now + TimeSerial(0, 0, 1), "UpdateTime"
End If
End Sub

Private Sub CommandButton1_Click()
    Range("K1") = Format(0, "00") & ":" & Format(0, "00") & ":" & Format(0, 
    "00")
    gbStop = False
    gdtStart = Now
    Application.OnTime Now + TimeSerial(0, 0, 1), "UpdateTime"

End Sub

Private Sub CommandButton2_Click()

    gbStop = True

End Sub

可用模块/表的屏幕截图

screenshot of the modules/sheets available