Using Macros To Get The Most Out
Of Excel Essay, Research Paper
As accounting professionals, accuracy in financial calculations and the integrity of the raw data are vital to producing useful information. Our clients prevail upon us to be more accurate and more thorough in less time. The tremendous advances in information technology are apparent across most industries. Accountants can gain much from this revolution through advances in spreadsheeting.
Microsoft Excel is an application that can produce an almost infinite number of financial calculations. A way to orchestrate a manipulation of data is to use spreadsheeting. Another more efficient way of manipulating or extrapolating data is by playing a macro.
A macro is a stored sequence of commands that can be imposed on data. Playing the macro initiates the sequence. When the macro is finished playing, the final manipulation or extrapolation is produced. This could be for example the production of a summary report.
An example of this is to view the information in a spreadsheet as raw data. (We must assume the data is all accurate otherwise rubbish in rubbish out). The data is strewn all over the spreadsheet. The macro can be seen as a filter. As we apply the macro to the data, it is like we pour the data through a filter. The information we need is collected in the filter.
Macros are more than just filters however. Using a real world example; an accountant is required to prepare a report showing the changes profit and loss figures over time for interpretation. The macro will not collect any existing data. It will manipulate the data and prepare a report showing percentages and ratios relevant to turnover and gross profit margins etc.
The macro provides this function repeatedly when applied to new data. It can save the time of manual calculation, or a tailored spreadsheet. And it improves accuracy.
Whilst Excel enjoys the reputation as the most widely used spreadsheet application , many users (not just the accounting fraternity) do not get all the power available from this enormously flexible application because they do not venture beyond basic spreadsheets or simple macros.
A recent discussion with a banker at ANZ mortgage services revealed that bank data is being converted from active data (spreadsheets with in-built commands) to raw data to be actioned by macros.
The reasons for the change are several.
When the active sheets have data changed, this has implications for the rest of the spreadsheet. All the linked cells will need to recalculate their cell values according to their formula. This takes time to execute. It may seem like a speed of light adjustment on a state of the art computer with a simple spreadsheet, however some of the Bank’s files were as large as fifty megabytes.
Another reason; the change in the file size when storing only data and not active spreadsheets. Commands such as “vlookup” take up large amounts of memory. When the files are converted to data only the files reduced in size from fifty megabytes to only five.
The final reason is that the data only files improve the integrity of the data. If one cell reference is interfered with or some code is inadvertently changes it can throw out the entire spreadsheet. If a macro is incorrect is can be corrected and applied to the data.
Macros are written in Visual Basic for Applications (VBA code). This is a powerful language that can be difficult to learn. For the beginner, Excel has a record Macro Function. This function records the commands that an individual makes as they are working on a spreadsheet. The sequence of commands can then be stored and replayed with new data.
Below are five years results for Evans Timber Pty Ltd.
My objective is to record a macro that provides the average growth figures over the five-year period. These figures will be represented as percentages in column “J”..
The record macro function is selected, Tools, Macro, Record new Macro. Every keystroke is recorded. The recorded macro is automatically converted into VBA. Even the revisions are recorded, as evidenced below.
Notice here that the “if” command was required. This nullified the prior formula, however the code is still recorded.
After the macro is completed the work done on the spreadsheet can be deleted and the macro applied to the raw data. This is done by Tools, Macro, Play Macro.
A screen will appear as follows, and the Average Growth macro is selected. Press Run and the commands are applied to the spreadsheet.
The results are the appearance of a new data column “J’ with average growth figures expressed as a percentage.
Whilst the record macro function is easy to use, it does have limitations. Most recorded macros are designed to perform a specific task. Most designers are also the users and being under time constraints take shortcuts. This means that the macros can become so specific they will not be useful in even a slightly different situation.
In the example performed above, what happens in the next year where there are six years of trading history? The recorded macro is rendered useless. Writing a macro in VBA can provide a tailored outcome no matter what the data range as the instruction can capture the data range until “blank”, rather than be limited to a prerecorded cell range.
Attempts to change prerecorded macros can become incredibly frustrating.
There are many commands that you need to learn to program VBA, one benefit of the record macro facility is that it can become a ready reference for the 300 VBA instructions.
In all the VBA component can allow for a myriad of functions that recording macros cannot.
There are plenty of texts and courses on writing VBA code. Or for free you can surf the net at www.add-ins.com/tricks.htm. or www.excelvba.com/?source=goto www.beyondtechnology.com/tips.shtml .
In short, be more professional by being more accurate, timely and providing accurate data.
(1) Beaman I. R., Ratnatunga, J. A., Krueger, P. and Mudalige, N. (1998). Financial Modelling, 2nd Edition, Quill Press
(2) Lee, J.C., (2000), Business and Financial Statistics Using Minitab 12 and Excel 97, Singapore, River Edge.
(3) Kyd, C. W., Kinata, C., (1992),Complete Guide to Microsoft Excel Macros, Microsoft Press
(4) Kinkoph, S., (1999), The complete idiots guide to Microsoft Excel 2000, Indianapolis Ind, Que.
(5) Albright, S. C., Winston, W. L., Zappe, C., (1999), Data Analysis ans Decision Making with Microsoft Excel, Pacific Grove CA, Duxbury Press.
(6) Berk, K.N., Carey, P., (1996), Data Analysis with Microsoft Excel, Pacific Grove, Microsoft Press.
(7) Wempen, F., Payne, D., (1999), The Essential Excel 2000 Book, Rocklin CA, Prima Tech
(8) Perry, G., (1999), Excel 2000 Answers!, Berkley, CA, Osbourne.
(9) Walkenbach, J., (1999), Excel 2000 Programming for Dummies, Foster City CA, Transworld.