if statements
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » If statements

If statements

resolvedResolved · Low Priority · Version 2003

replyReply Mon 6 Oct 2008, 16:32Delegate Claire said...

Claire has attended:
Excel VBA Intro Intermediate course

If statements

How do you enter multiple if statements in VBA?

For upcoming training course dates see: Pricing & availability

replyReply Fri 24 Oct 2008, 11:05 Edited on Fri 24 Oct 2008, 11:05Trainer Laura said...

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

 

Please browse our web site to find out more about
advanced excel class and other Microsoft training courses.

Excel tip:

Viewing two Excel 2010 Workbooks at the same time

Did you know you can view two Excel 2010 workbooks side by side? Very useful when comparing data without constantly having to go back and forth!

1) Open both Excel workbooks
2) Select Window then select Compare Side by Side with (Spreadsheet 2)
3) When you have finished, select Window again and click Close Side by Side

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard