
Not just with this code, whenever you record a macro, you need to clean it up every time.īut before you start cleaning up this code you need to remember about the four activities which you have performed and for which you need to have code in your module: There are a lot of properties included in this code that are not required. If you look closely, it’s way longer then the activities it can perform. 'font style Verdana, and makes the font bold 'This macro applies a red color, font size 12,
At last, in the fourth part, it says the font in the selected cell should be bold.Īt this point, you have recorded your first macro and you know how that code gets generated.īut you need to clean up the code that you have in the module. And in the third part, it says the font style of the should be “Verdana”. The second part of the code, says the font size of the selected cells should be “12”. In the first part, the code says the font color of the selected cell should be red, and it has used a numeric value for it. So for this, open the Visual Basic Editor, go to Developer tab ➜ Visual Basic editor. To understand this, you need to see the code first. The macro recorder generates a code for you at the back end when you are performing the activities. Once you do this, go back to the developer tab and click “Stop Recording” or you can also stop recording from the status bar where it says “click here to stop recording”.Ĭongratulations! You have made it and at this point, you have a recorded macro in your workbook but now the next thing is to understand it. So now, apply all the four formattings which we have decided. At this point, Excel’s stars to record everything (you can see the icon on the status bar which says “A macro is currently recording, click to stop recording”). Description: This macro applies a red color, font size 12, font style Verdana, and makes the font bold. Store Macro in: Select Personal Macro Workbook.
Shortcut Key: Press Shift + H to define the keyboard shortcut Control + Shift + H. And the moment you click it you’ll get a dialog box to fill some of the details about the macro you are going to record (yes, we need to fill it). After that, go to the “Developer Tab”, and before you hit the “RECORD” button, Turn ON the relative reference (we are going to learn about it in a few minutes). First of all, select cell A4 (it’s the cell we are going to apply the formatting and recording of our macro). To RECORD a MACRO in Excel, you can use the following steps: Steps to record a macro using the macro recorder So when you rerun this macro, it will select that particular cell to apply all the formatting on it.īut what we want is to apply the formatting on the cell, which is active (which is selected).ĭownload this macro-enabled file to follow along. The reason for this is if we select a cell while recording the macro, it will record that selection as well.
Here we are going to record a macro which can make apply following formatting to the selected cell:Īs I said, planning is essential, and before recording this macro, there’s one thing we need to take care of, and that is selecting the target cell before actually starting recording. The best way for this is to note down the steps you need to perform and then stick to it while recording. The thing is, you don’t want to get a code for the activity which you don’t want to execute while using the recorded macro again. Word copies the macro from the left Macros panel to the right Quick Access Toolbar panel.In the same way, for recording a macro, it’s essential to do some planning. On that screen, locate your macro, select/highlight it, then click Add. Click Button and the Word Options/Customize Quick Access Toolbar screen opens. Step 2: Add a macro button to the Quick Access ToolbarĪ. Even though you can overwrite many of these shortcuts, it’s much easier to attach your macro to a button.
Note: Most of the shortcut keys are already used by the system. Next, in the Assign Macro To panel, click Button or Keyboard (shortcut) for the method used to access and run the macro. For the Store Macro In field, choose All Documents to run this macro in all of your Word documents, or select the current document (displayed by filename) to use this macro in the current document only. Descriptions are just notes that summarize the macro’s function.Ĭ.Macro names cannot conflict with the program’s reserved commands or keywords such as Print, Save, Copy, Paste.Macro names can be 80 characters maximum.You cannot use spaces, non-alphanumeric characters, or periods. Macro names must begin with a letter and use either letters or numerals.