gpt4 book ai didi

button - Excel 2010 - 禁用按钮

转载 作者:行者123 更新时间:2023-12-03 03:00:06 26 4
gpt4 key购买 nike

我的电子表格上有 3 个不同的表单按钮。我想在按下其中一个时禁用其中两个。这可能吗?

在 C# 中,按钮可以是 true 或 false,但我在 VBA Excel 2010 中找不到任何这样的示例?

提前致谢

最佳答案

您无法禁用表单按钮。如果您想使用该功能,请使用 ActiveX 按钮。

但是还有一个替代方案。创建2个公共(public) bool 变量,然后在按钮1的单击事件中将变量设置为True或False。根据 bool 变量,其他 2 个按钮是否运行其代码。例如

Option Explicit

Dim enableB2 As Boolean, enableB3 As Boolean

Sub Button1_Click()
If enableB2 = False Then
enableB2 = True: enableB3 = True
Else
enableB2 = False: enableB3 = False
End If

'
'~~> Rest of the code
'
End Sub

Sub Button2_Click()
If enableB2 = True Then
'
MsgBox "Hello You clicked Button 2"
'
End If
End Sub

Sub Button3_Click()
If enableB3 = True Then
'
MsgBox "Hello You clicked Button 3"
'
End If
End Sub

关于button - Excel 2010 - 禁用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10700398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com