Probably an easy one but my prog skills are limited. I've created an account entry tool and want to warn the user if they've entered a credit amount for an Expenditure type of which there are two types; "Restricted_Expenditure" and "Unrestricted Expenditure". Typically values of this type should be debits.
I can get it to work for one type in the statement, but not if I add the other expenditure type in an "or" statement.
Any help appreciated - is there an "Or If..." type function I could use?
My code is
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
This question is related to
vba
excel
if-statement
In VBA we can not use if jj = 5 or 6 then
we must use if jj = 5 or jj = 6 then
maybe this:
If inputWks.Range("d9") > 0 And (inputWks.Range("d11") = "Restricted_Expenditure" Or inputWks.Range("d11") = "Unrestricted_Expenditure") Then
Source: Stackoverflow.com