用户表单复选框:如果出现错误,则结束,如果没有阻止



如果选中VBA用户表单复选框,则尝试使单元格P3显示"真"或"是"。

任何提示都会有所帮助。下面的代码导致编译错误:结束如果,没有块如果错误。

If CheckBox1.Value = True _
Then Range("P3").Value = "True"
End If

首先,如果你想在额外的行上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

最新更新