Jump to content
News Ticker
  • Welcome to the Community
  • Use the forum to troubleshoot your Excel & VBA Problems
  • We will be launching a new website soon! www.ExcelWTF.com/Learn ! Join us to learn VBA from the ground up!
Sign in to follow this  

[Course] What is Object Oriented Programming (OOP)?

Recommended Posts

1. What is Object Oriented Programming (OOP)?

1.1 Introduction

Let's kick things off with a quote for no apparent reason - "To understand how things end, you must first understand how they begin"

That's pretty much what this section is all about. Unfortunately we wont be coding anything just yet, we'll get to that soon :thumbup: For now I'll give you a brief overview of what OOP is and why it's a great model to use. Don't skip over this module, it's vital to understand the principle herein, and it will help you when you're coding like a ninja in a few weeks time (trust me  ;) )


1.2 Is OOP a programming language? I came here to learn VBA! 

OOP can be described as a programming language model. It is not a language itself, but more so a type/style of language. Visual Basic for Applications (VBA) is a programming language that adheres to the OOP model. The OOP model puts focus on working with Objects rather than simply carrying out sequential actions. Each Object can hold information (but only information that is relevant to it) through the use of Properties. Furthermore, each Property of an Object can be controlled or influenced by programming Methods


I know this may sound like i'm talking in dothraki (Game of Thrones anyone?), but these sorts of terms (Object, method, property) will all become clear to you soon. 


1.3 OK, so what is an OOP Object? Method? and a Property?

The best way to explain what an Object is by using a visual aid... which i totally have copyright permission to use...  :silent: 



You may recognise this as a bicycle. A bicycle, in the real world, is an Object or a tangible 'thing'. With this  object we can do many different things, such as:

  • Ride it (Method) ----> to change its location (Property)
  • Paint it (Method) ----> to change its color (Property)
  • Inflate the tyres (Method) ----> to change its bounciness? (Property)

So we can take an Object (bicycle) and apply a Method (Painting) in order to change its Property (color). Hopefully that shows you the link between these 3 bits of programming jargon.


Now you're probably wondering, wtf is this? There are no bicycles in Excel.... Whilst that is true, it's important to understand how these link together. Mission Accomplished.... i hope (leave a comment down below!). 


1.4 Are you going to teach me about VBA or not?

Okay okay, lets get into VBA and how this all ties together. Remember how I said VBA is follows an OOP model? Well... VBA must have some Objects, Methods and Properties then right? Yes it does! Here are some examples:

  • Objects: Workbooks, Worksheets, Rows, Cells etc (All things that we can Apply a Method.. to do things TO them)
  • Methods: Find, Replace, Open, Close, Copy (all things we can DO with the objects above)
  • Properties: Cell Color, Font Size, Value (something that is quantifiable and can be measured)


Now as I said before... not all Methods can be used on all Objects. To use a real life example... Your 'elbow' is an Object, 'Licking something with your tongue' is a Method. Now try licking your elbow... If you were successful, go and see a doctor... your tongue shouldn't be that long! :D For the rest of us, we were Stopped from licking our elbow by our bone structure! 


In a similar way, VBA limits which Methods (and Properties) can be used/changed for each Object. For example you can't 'Open' (Method) a 'Cell' (Object)... (unless you're in prison) #TerribleJoke


1.5 How am I meant to learn what all these objects are? And how I can influence them in my code?

In truth, there are many Excel Objects, with thousands of methods and millions of properties. There is no point going through all of them 1-by-1, mainly because my fingers are getting tired of typing, but more so because for the type of work most people will use VBA for; we wont need to use them! I will show you the most important programming excel objects, methods and properties within this course (in future threads). 


Quote of the day: "I will do anything humanly possible... to reach the remote without getting up!"

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...