Mar*_*ant 3 excel vba if-statement excel-vba
可能很简单,但是我的编步技能却很有限。我已经创建了一个帐户输入工具,并希望警告用户是否为两种类型的“支出”类型输入了信用额度;“限制支出”和“非限制支出”。通常,此类型的值应为借方。
我可以使它适用于语句中的一种类型,但是如果我在“或”语句中添加另一种支出类型则不能。
任何帮助表示赞赏-我可以使用“ 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
Run Code Online (Sandbox Code Playgroud)
在VBA中我们不能使用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
Run Code Online (Sandbox Code Playgroud)