How to Write Macros for Graphs in Excelby Bradley James Bryant
Macros provide users of Excel with the ability to automate common functions by creating your own program. This program can then be accessed through the macro menu or with a new keyboard shortcut, i.e., "ctrl+v", which is the keyboard shortcut for "paste text" on most computer operating systems. You can create a macro to do any set of tasks through Excel, even create a graph.
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.
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.
Go to the Tools menu. Click on "Macros" and "Record New Macro".
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.
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".
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".
Click here to provide feedback on this article