【发布时间】:2016-04-25 09:51:07
【问题描述】:
可能很简单,但我的编程技能有限。我创建了一个帐户输入工具,并希望在用户输入有两种类型的支出类型的贷方金额时警告用户; “Restricted_Expenditure”和“Unrestricted Expenditure”。通常这种类型的值应该是借方。
我可以让它适用于报表中的一种类型,但如果我在“或”语句中添加另一种支出类型,则不能。
任何帮助表示赞赏 - 我可以使用“Or If...”类型的函数吗?
我的代码是
If inputWks.Range("d9") > 0 And inputWks.Range("d11") = "Restricted_Expenditure" Or "Unrestricted_Expenditure" Then
Dim Response As Integer
Response = MsgBox(prompt:="You've entered a credit amount against an expenditure type. If this is correct then press 'Yes' or else press 'No' to change", Buttons:=vbYesNo)
If Response = vbYes Then
GoTo Line1
Else
Exit Sub
End If
【问题讨论】:
-
你看过
ElseIf吗? -
这就是你的全部代码吗?因为如果是这样,你就错过了 End If 语句,但它可能会出现,如果它不是所有代码:)
标签: vba excel if-statement