Browse » Home
Thursday, July 14, 2011
How to Write Macros for Graphs in Excel
1. Map out the process. You can create a graph from a macro as long as the process is always the same; that is, you will need to pick the same graph type every time. The best way to ensure you don't miss any steps is to map the process out first on a piece of paper. You can write out steps or use blocks and arrows, whichever is most comfortable and easy to read. This process has the potential to save a lot of time in terms of reducing trials and errors.
2. Open the report you want to create a graph for. The challenge with creating a macro for graphs is that the information must be pulled from the same section each time in order for the macro to work. That is, the best way to run a graphing macro is to use it on a report where the formatting stays the same, but the numbers change. This means the numbers which are being graphed are always in the same place.
3. Go to the Tools menu. Click on 'Macros' and 'Record New Macro'.
4. Create the macro name and keyboard short-cut. You can choose anything you want, but let's go with 'Graph' and 'ctrl g' for this example.
5. Begin creating the graph. Once you create the name the macro will begin to record your commands. There are many ways to create a graph, but the easiest is to click on the graph icon in the standard toolbar. This icon looks like a chart. Walk through the wizard, step by step. Each choice will also be chosen in your macro command. When finished click 'OK' and 'Stop Recording'.
6. Run your macro. You can access your graphing calculator in two ways: 1) go to the Tools menu and then click on 'Macros' to see a list of the macros created by name, choose 'Graph' and the select 'Run'; or, 2) hold down the 'ctrl' key and press 'G'.