我有这个宏
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim x As Integer
Dim S1 As String
Dim S2 As String
S1 = "Football"
S2 = "Basket"
x = 1
Do
If IsEmpty(Cells(x, 5)) And ((Cells(x, 3) = S1) Or (Cells(x, 3) = S2)) Then
MsgBox "Insert a value in the empty cell"
Cancel = True
End If
x = x + 1
Loop Until Cells(x, 1) = ""
End Sub
当我单击“x”按钮关闭工作表时,如果第 5 列为空并且第 3 列包含Football
或Basket
宏进行控制并出现一个消息框以提醒您已插入一个值。检查通过但我不知道MsgBox
出现 16 次而不是 1。为什么?