Join Curt Frye for an in-depth discussion in this video Controlling procedure scope and visibility, part of Learning VBA in Excel.
When you create a macro in Microsoft Excel, that macro can be seen and run by…any procedure in any open workbook.…If you want to control that macro's visibility or scope, you can do so by using…the Public and Private keywords.…Excel assumes that any macro you create in a General code module should be…available to be run from every open workbook.…I'll show you what that looks like in my workbook here.…I am in Module 1, and this is a General code module.…These are the worksheet and ThisWorkbook code modules here.…Down in the Module section, you'll find what are called General code modules.…
If you want a macro to be available for running in any open workbook, you can…either type the Public keyword in front of your macros opening Sub statement,…like this, or you can leave it out.…Now, with the Public keyword set -- well, actually I will delete it, just to…show you the default case,…in other words, if you put nothing in front of the Sub declaration -- and now I'll…switch back to the main workbook, and I will create a new workbook by pressing…
- 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 2010: Tips, Tricks, and Shortcutswith Dennis Taylor3h 43m 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.