VBA:消息框显示,条件循环
VBA: Message Box Display, Loop on Condition
我创建了 VBA 代码,当满足特定条件时显示消息框。此 if 语句循环遍历确定的范围。但是,会为满足我的条件的每个单元格显示消息框。有没有办法确保消息框只显示一次?
这是我的代码:
Private Sub Worksheet_Change(ByVal Target As Range)
For Each cell In Range("S194:BZ194")
If cell.Value < 0 Then
MsgBox "Unrestricted cash cannot be less than zero (Row 194). Please lower the loan growth rate."
End If
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
For Each cell In Range("S194:BZ194")
If cell.Value < 0 Then
MsgBox "Unrestricted cash cannot be less than zero (Row 194). Please lower the loan growth rate."
Exit For
End If
Next
End Sub
我创建了 VBA 代码,当满足特定条件时显示消息框。此 if 语句循环遍历确定的范围。但是,会为满足我的条件的每个单元格显示消息框。有没有办法确保消息框只显示一次?
这是我的代码:
Private Sub Worksheet_Change(ByVal Target As Range)
For Each cell In Range("S194:BZ194")
If cell.Value < 0 Then
MsgBox "Unrestricted cash cannot be less than zero (Row 194). Please lower the loan growth rate."
End If
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
For Each cell In Range("S194:BZ194")
If cell.Value < 0 Then
MsgBox "Unrestricted cash cannot be less than zero (Row 194). Please lower the loan growth rate."
Exit For
End If
Next
End Sub