我编写了这个简单的 VBA 代码来包含开始和停止按钮。在我单击 On 按钮启动 Do 循环后,excel 保持忙碌状态,我无法单击 Off 按钮停止循环。你能帮忙吗?
Public ONOFF As Boolean
Sub ON_Button()
ONOFF = True
Do While ONOFF
Matha
Loop
MsgBox ("Exit Matha sub")
End Sub
Sub OFF_Button()
ONOFF = False
End Sub
Sub Matha()
Dim X, Y, Z
X = 1
Y = 2
Z = 5
Z = X * Y + Z
End Sub