Excel VBA中的IF语句中的多个条件

可能是一个容易的,但我的编程技能是有限的。 我已经创build了一个帐户input工具,并且想要警告用户,如果他们已经为两种types的支出typesinput了信用额度; “限制性支出”和“不受限制的支出”。 通常这种types的值应该是借方。

我可以在声明中将其用于一种types,但是如果我在“或”声明中添加其他支出types,则不能。

任何帮助表示赞赏 – 有一个“或如果…”types的function,我可以使用?

我的代码是

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 

在VBA中, if jj = 5 or 6 then我们就不能使用if jj = 5 or 6 then我们必须使用if jj = 5 or jj = 6 then

也许这个:

 If inputWks.Range("d9") > 0 And (inputWks.Range("d11") = "Restricted_Expenditure" Or inputWks.Range("d11") = "Unrestricted_Expenditure") Then