Join Curt Frye for an in-depth discussion in this video Introducing object-oriented programming, part of Learning VBA in Excel.
If we are going to talk about Visual Basic for applications, which is a programming language, first, we need to discuss what exactly is a programming language? For our purposes, it's just a system statement you use to manipulate a computer. At a minimum, you need to be able to put data into the computer, store it there, manipulate the data, and produce output. So, with that perspective in mind, let's talk about Visual Basic for applications, which is an object -oriented programming language. Object-oriented programming focuses on the objects involved in the calculation. In Excel, you would think of a workbook, or a worksheet, or perhaps a range of cells, as an object.
Well, let's talk about something that's probably more familiar, something that you interact with everyday: an automobile. You can describe the car, specify actions you can perform with the car and enumerate things that can happen to the car. These three types of characteristics form the backbone of object-oriented programming. Descriptive items are called Properties. For a car, you could have properties that store the cars manufacturer, model, year, color and price. Actions you can perform with the car are called Methods, and are described using the verbs; for example, you can drive a car, park a car, or wash a car.
Things that can happen to a car are called Events. Some events mirror the object's methods, such as a car being started or being parked. The difference is that when an event such as a car being started occurs, the program detects the change in the car's state and runs any instructions you want to be run when that event occurs; for example, your car's onboard computer could be programmed to turn on the car's headlights when you start it. If you create an event called Car On_Start, the instructions you include in that event's definition will run whenever someone starts the car. Object-oriented programming is a powerful paradigm, especially when you use it to work with programs such as Microsoft Excel.
But at its base, it's just another way of organizing the same Properties, Methods, and Events in every other programming language. In the next movie, I'll introduce the Excel Object model, which gives you the hooks you need to manipulate Excel workbooks, worksheets and the application itself.
- 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.