98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » If statements
If statements
Resolved · Low Priority · Version 2003
Claire has attended:
Excel VBA Intro Intermediate course
If statements
How do you enter multiple if statements in VBA?
RE: If statements
Hi Claire
Thank you for your question regarding If Statements.
To use multiple Ifs in VBA you use an ElseIF. Be careful to make sure the ElseIf is one word. The syntax is very similar to the If line. You can have as many ElseIf lines inside your If statement as you like.
Example If Statement
Function Bonus(iSales As Integer, iTarget As Integer) As Integer
If iSales > iTarget Then
Bonus = 3000
ElseIf iSales = iTarget Then
Bonus = 2000
Else
Bonus = 250
End If
End Function
I hope that answers your question.
Laura GB
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:How to select certain data in an Excel 2010 workbookIf you want to select the correct data set in a page full of data, the most accurate and efficient way of doing this is to use the ''Shift and Click'' technique. |