nested ifs vba
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this 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 » Nested Ifs in VBA

Nested Ifs in VBA

resolvedResolved · Low Priority · Version 2003

replyReplyFri 21 Aug 2009, 15:45Delegate Dimitrios said...

Nested Ifs in VBA

I had created a piece of code trying to test some data adn I had to use numerous if statements. Peter suggested that using the Case function would be better and more effiecient. How exactly can I replace Ifs with Cases?

For upcoming training course dates see: Pricing & availability

replyReplyMon 24 Aug 2009, 15:00Trainer Simon said...

RE: Nested Ifs in VBA

Hi Dimitrios,

Thank you for your question.

You start with 'Select Case' and the name of the variable.

E.g. Select Case MarkUp

Multiple conditions are handled by 'Case Is'.

E.g. Case Is MarkUp > 2000

Underneath each 'Case Is' you type the true answer.

E.g. Case Is MarkUp > 2000
Commission = MarkUp * 0.05

Case Is MarkUp > 1000
Commission = MarkUp * 0.03

Continue this pattern until all the conditions have been entered.

Use 'Case Else' to input the answer for all the remaining values not covered by the conditions.

E.g. Case Else
Commission = 0

Finally you need to close the Select command with:

E.g. End Select

I hope this answers your question.

Regards

Simon

 

 

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

Excel tip:

Fill formulae across a sheet

To copy a formula down a spreadsheet where there is data underneath, to the left or to the right of the formula, double-click on the fill handle. The fill handle is the little black cross that appears in the bottom right-hand corner of the formula cell. Unfortunately, no similar facility exists to copy formulae across the sheet.

One reasonably quick way to copy an existing formula across a sheet is to select the formula and the cells on the right to which you want to copy it. Then press Ctrl+R to copy the formula across the selected range, or, if you are menu-minded, use the Edit|Fill|Right command.

View all Excel hints and tips

forum postDo the same commands in excel 2003 work in 2007 (e.g. setting up a pivot table) or is re-training required for 2007?

» Forum post: Excel versions


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training