【发布时间】:2025-11-26 00:50:01
【问题描述】:
如果选中 VBA 用户表单复选框,则尝试让单元格 P3 显示“True”或“Yes”。
任何提示都会有所帮助。下面的代码导致编译错误:End If with no block if error。
If CheckBox1.Value = True _
Then Range("P3").Value = "True"
End If
【问题讨论】:
标签: excel vba checkbox userform
如果选中 VBA 用户表单复选框,则尝试让单元格 P3 显示“True”或“Yes”。
任何提示都会有所帮助。下面的代码导致编译错误:End If with no block if error。
If CheckBox1.Value = True _
Then Range("P3").Value = "True"
End If
【问题讨论】:
标签: excel vba checkbox userform
首先,如果您想在额外的行中添加then,您必须这样写
If CheckBox1.Value = True _
Then
Range("P3").Value = "True"
End If
其次,CheckBox1.Value = True 也不是必需的,因为 CheckBox1.Value 是 boolean 类型。
我喜欢的一段代码可能看起来像这样
If CheckBox1.Value Then
Range("P3").Value = "True"
End If
【讨论】: