Join Curt Frye for an in-depth discussion in this video Managing variable scope, part of Up and Running with VBA in Excel.
In an earlier movie, I showed you how you could limit a procedure's availability…by placing it in a worksheet's code module or make the procedure available to…the entire workbook, by placing it in a regular code module.…The range for a procedure's visibility within a workbook is called its Scope.…You can also change how variables behave within your workbook by managing their scope.…As an example, let's use the code in this workbook. I'll press Alt+F11 to jump…over to the Visual Basic Editor.…When you declare a variable in a subroutine, that's the only subroutine that…knows about it, as an example, both of these subroutines use the same variables,…but the one I would like to focus on is the rate.…
In this subroutine, I assign the value 0.05 or 5% to the rate. In the second…subroutine, in the bonus commission subroutine I assign the value of 8%, or .08.…Now let's see what happens when I run the two subroutines.…If I run the first one, based on the value and cell C7 on the commission…worksheet, I get the value of 312.51.…
- 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
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.