Join Curt Frye for an in-depth discussion in this video Performing a task when conditions are met using If...Then, part of Learning VBA in Excel (2010).
So far, most of this courses example files have contained subroutines or…functions that run every time you call them.…There will be times, though, when you want parts of your subroutines to run when…the condition is true.…In business, the canonical example is calculating sales commissions.…Many companies have separate commission rates for different sales totals.…So I'll use that example to show you how you can use If-Then statements to…execute code conditionally.…The data we'll work with is just this single sale amount, currently set to $1400.25.…So how can I interact with that using VBA code?…Well, let me press Alt+F11 to switch over, and I will show you.…
The first type of If-Then statement you can create is called the IIF statement.…The IIF statement is the equivalent of the worksheet's If function. The If…function, and I'll switch back to show you how it works, is =if and then you…have a logical test.…In this case, I will test to see if the value in cell C5 is greater than 1400.…Then you type comma and you tell Excel what to do if the value is true.…
- Working in the Visual Basic Editor
- Adding code to a macro
- Creating, exporting, and deleting code modules
- Declaring and using variables
- Managing variable scope
- Defining arrays
- Managing workbooks and worksheets with VBA
- Repeating tasks with loops
- Debugging VBA code
- Cutting, copying, and pasting cell data
- Running and triggering event procedures
Skill Level Advanced
Excel 2016: Power Query (Get & Transform)with Oz du Soleil1h 49m Intermediate
1. Introducing Visual Basic for Applications (VBA)
2. Defining Variables, Constants, and Calculations
3. Adding Logic to Your VBA Code
4. Debugging Your VBA Code
5. Managing Workbook Elements and Data in VBA
6. Adding Advanced Elements to Your Workbook
7. Using Excel Events in Your VBA Code
8. Putting It All Together
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.