Skip to main content

Easy - Getting Started With Excel VBA(Free Tutorial)

This is a brief introduction to VBA which stands for Visual Basic for Applications. It is a standard programming language for Microsoft applications such as Word and PowerPoint and you can use VBA to automate tasks within Excel or within other applications. You can also use VBA if you want these applications to talk to each other. So you can extract a report from excel and put it in PowerPoint or in word or you can do a lot of automation within Excel. You can also use VBA to do a lot of stuff that you cannot do in Excel by itself. So you can create many new functions, you can use a lot of new functionalities which Excel does not provide in its basic form.

What can you do with VBA?

  • You can automate a series of tasks if for example you get a report from a database or you get many reports from colleagues and you have to apply a certain formatting each and every time you get that report then you can automate this task. You can write a code in the backend and with a single click or with a single shortcut all these tasks can be done within a twinkling of an eye because you have automated it using VBA.
  • You can also create custom functions that do not exist in Excel. Say for example you want your VLOOKUP( ) function to extract all the values that are occurring for a particular block of values and put it in a single cell then you can do that but you cannot do that with the VLOOKUP function that provided within excel. You can create custom functions.
  • Create add-ins that can do a lot of work within Excel.
  • Create applications. Now these applications that are built using VBA may not even look like a spreadsheet but its so powerful that you can create these applications and do a lot of stuff.

What are the building blocks of VBA?

VBA is a very simple language. All you need to know is how its building blocks come together to make this language and you also need to know the syntax. Here are a couple of tings that make up VBA.

  • Sub/Procedure - This is the place where you put your code. It means you write your code within the sub.
  • Functions - You can use VBA functions or create custom functions.
  • Events- This is where you can ask VBA to execute a code when an event happens. For example when you double click on a cell, you want something to happen so that's an event based VBA procedure.
  • Objects - This means everything in Excel is an object. Whether its a chart or worksheet or a workbook.
  • Variables

These will be used continuously to build code and get the work done.

Object Oriented Programming

VBA is one of the object oriented programming languages. If you have not heard this terminology before here's a simple example that will help you understand the concept behind object oriented programming. Sometimes written as OOP. 

Assuming I would like to apply a green background colour to cell B2 in the worksheet(Sheet1), in workbook(example.xlsx) in the application which is Microsoft Excel. 

I would start from the outside going in and that would be with the application(Excel) and tell VBA that I would like to do something within Excel. 

Within Excel I would have to go to the Workbook(example.xlsx). 

Within the workbook, I have a worksheet whose name is Sheet1. A workbook can have many worksheets but I am only interested in Sheet1. 

Within the worksheet(Sheet1) I have to locate cell B2 within which I change the colour. 

This is a simple illustration of how Object Oriented Programming works.

Microsoft Excel -> Workbook(example.xlsx)-> Worksheet(Sheet1)-> Cell B2-> Change background colour.

This means you need to know the cell address in order to make any changes to it such as changing the colour, copying, deleting etc.and that requires knowing how to qualify that object. To understand OOP better, you can read more about it on Wikipedia.

I would love to hear from you, so leave any questions or comments below and I will get back to you as soon as possible.

Cheers!

Comments

Popular posts from this blog

Fun Terminal Commands Every Linux User Should Try

Accessing Maps from the terminal with MapSCII Requirements Telnet installed Internet Connection Firewall is disabled You can do this on Linux, Unix, Mac OS X or Windows with an app like PuTTY or the Windows 10 Linux bash shell or any Os that supports telnet. Open terminal and write the command below. telnet mapscii.me Hit enter and you're ready to browse and enjoy MapSCII. Navigate using the keyboard or mouse. Use the following keys on your keyboard Arrow keys: up, down, right, left A to zoom in Z to zoom out C toggles ASCII mode on/off You can also click and drag and hold on the map with your cursor. If your connection dropped without a reason, reconnect with telnet -E mapscii.me and use only cursors, A and Z to navigate. The Mapscii project is open source and you can install it locally if you'd like. Check out their project here on GitHub . The Dancing ASCII Party Parrot Requirements Curl installed Internet

SQL for Data Analysis - Udacity

  Entity Relationship Diagrams An  entity relationship diagram  (ERD) is a common way to view data in a database. Below is the ERD for the database we will use from Parch & Posey. These diagrams help you visualize the data you are analyzing including: The names of the tables. The columns in each table. The way the tables work together. You can think of each of the boxes below as a spreadsheet. What to Notice In the Parch & Posey database there are five tables (essentially 5 spreadsheets): web_events accounts orders sales_reps region You can think of each of these tables as an individual spreadsheet. Then the columns in each spreadsheet are listed below the table name. For example, the  region  table has two columns:  id  and  name . Alternatively the  web_events  table has four columns. The "crow's foot" that connects the tables together shows us how the columns in one table relate to the columns in another table. In this first lesson, you will be learning the bas

Impressive - Check if Your Email Address Has Been Hacked - Free,Easy Tutorial

haveibeenpwned.com Data breaches are rampant and many people don't appreciate the scale or frequency with which they occur. A "breach" is an incident where data is inadvertently exposed in a vulnerable system, usually due to insufficient access controls or security weaknesses in the software. How is the legitimacy of a data breach established? Attackers often give "breach" announcements, which are later revealed to be hoaxes. There is a delicate balance to be struck between making data searchable as soon as possible and conducting proper due diligence to confirm the breach's validity. In order to verify the authenticity of a violation, the following steps are normally taken: Has the affected provider made a public statement about the security breach? Does the information stolen in the breach show up in a Google search (i.e., it was simply copied from another source)? Is the structure of the data consistent with what you'd expect to see in a breach? Have