Paul is a GIS professor at Vancouver Island U, has a PhD from U of British Columbia, and has taught stats and programming for 15 years.
Computers are great for carrying out tasks that would otherwise be tedious or impossible. Just think of having to type out a report using a typewriter or doing complex calculations by hand using pencil and paper. In many ways, computers have made our lives easier. However, many computer users still often perform very repetitive tasks, such as filling in forms or typing out memos. In this lesson, we will look at some ways to change that.
Let's say you are a financial analyst working for a large financial services firm. One of your tasks is to brief your team members on the latest market conditions. Every day at 8:00 a.m. you sit down at your desk, and you go through the same routine.
You log on to your computer, and you visit about 10 different financial websites. From each site, you download a report or copy some selected financial indicators. You put all this information into a spreadsheet, and you've come up with some clever formulas to describe the present market conditions based on the raw data. You send out this summary report to all your team members at 9:00 a.m. so they can refer to it throughout the day.
You have become very efficient at producing this report, but the websites change their reports daily, and it just takes one hour to get all the information collected, organized and analyzed. What if there was a way for you to have this report done, not at 9:00 a.m., but at 8:01 a.m.? Now that would be cool. What you need is a macro.
What Is a Macro?
A macro is a set of computer instructions that you can record and execute later as needed. You carry out the particular steps once, and the sequence of steps is recorded. You then associate the steps with a shortcut key combination or a macro name. When you press the shortcut key combination or click the macro name, your computer program carries out the same instructions that were previously recorded. This can save a significant amount of time by replacing a series of frequently used actions with one much shorter action.
Macros have a number of potential benefits, including:
• Automate repetitive computer tasks
• Carry out tasks faster than a human computer user
• Complete tasks more reliably without human errors
• Reduce stress and boredom of computer users
Types of Macros
Broadly speaking, there are two types of macros of interest. The first one is called an application macro. This is a macro that is recorded and executed within a single software application. A good example of this would be a spreadsheet application, like Microsoft Excel. Spreadsheets contain many functions for processing of numerical data, but you will often need to create your own sequence of processing and analysis steps. This could be as simple as typing in a series of numbers or as complex as a predictive statistical model.
Within the software application, you start recording your macro, carry out your steps, and stop recording. When you run the macro the next time, it will carry out the exact same steps. The ability to record and run macros is a built-in function of the software application.
Technically speaking, the software converts your steps to instructions written in a particular programming language that works with the software. Which language is used will depend on the software application. Microsoft Office applications have traditionally used Visual Basic for Application, or VBA, as the default language for creating macros.
The second type is a generic macro that works at the operating system level. This means you are not limited to one software application. Your macro can be used to open a web browser, go to a website, download a file, open this file up in an application and then manipulate the data. This starts to look like the type of macro our financial analyst wants to use.
This type of macro typically requires a specialized software application created for the specific purpose of creating macros. This type of software is sometimes referred to as automation software. Both types of macros use the same logic: your record a series of steps that are saved for later execution. The series of steps can be executed on demand with a single button-click.
Considerations When Using Macros
Returning to our financial analyst, it will take some time to get the entire series of steps recorded, but once that is done, the macro will execute and produce the desired report. If all goes well, the report will be ready at 8:01 a.m. And you can also schedule your macro to execute at a particular time. So, you can execute your macro at 7:30 a.m. and have it e-mail the report to all your team members before you even get to work!
There are, however, some disadvantages. A macro executes the steps exactly as recorded. For example, if a key financial indicator was located on the third line of a report during the recording, the macro will always look for this indicator on the third line. What if the reporting format has changed and the indicator is now on the fifth line? The macro will use whatever is on the third line and may crash if that information does not make sense.
Do you have to re-record the entire macro? Not necessarily. Depending on the software used to create the macro, you can update only the parts that need to be changed.
Macros vs. Programming
Reconsider the definition of a macro for a moment: a set of computer instructions that you can record and execute later as needed. Doesn't that sound a bit like programming, i.e. writing instructions for a computer to execute? Indeed. Macros are a form of programming, but a very unique form.
Recall that our analyst did not actually write any code but recorded a series of steps. The use of recording is the key difference. A programmer writes code in a specific programming language and then executes the program.
When you create the macro, the code is written by the software that records the macro. You do not actually need to see this code to use the macro. Being able to read and edit this code is a useful skill but not required to use macros.
Our financial analyst could have used programming to automate his tasks, and in some cases that may be the best solution. However, this requires having to learn how to program or calling in the expertise from someone who can. For relatively basic tasks that need to be repeated very frequently, macros can be a very effective alternative to developing a custom program.
A macro is a set of computer instructions that you can record and execute later as needed. You manually carry out the particular steps once. The sequence of steps is recorded as a macro, and this macro can then be run at any time.
Macros can be created and executed within a single software application or by combining steps in multiple applications. The latter requires the use of automation software. Using macros is a special type of programming. Recorded steps are converted into code, but you generally don't need to write code to use a macro.
Following this lesson, you should be able to:
- Define macros and explain the advantages of using a macro
- Describe the two types of macros
- Identify the limitations or disadvantages of macros
- Explain how macros and programming are similar and how they are different
To unlock this lesson you must be a Study.com Member.
Create your account
Register to view this lesson
Unlock Your Education
See for yourself why 30 million people use Study.com
Become a Study.com member and start learning now.Become a Member
Already a member? Log InBack