【发布时间】:2022-11-14 15:20:47
【问题描述】:
如果单元格 B34 > 0,有没有办法防止 Excel 关闭和J34 = 0?
如果他们不理会 B34,则不需要填写 J34,并且可以关闭工作簿。
如果他们将数据输入 B34,我们也需要 J34 中的信息。
像这样的东西:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.Sheets("Sheet1").Range("B34").Value > "" and _
Application.Sheets("Sheet1").Range("B34").Value = "" Then
Cancel = True
MsgBox "Please fill in the total % in cell J34"
End If
End Sub
【问题讨论】:
标签: excel vba conditional-statements