
The other method is to go to “View” tab.The easiest and quickest method is to click the macro recording indicator located to the left of the status bar.You have two options here to stop recording the macro. Step 07: Stop recording the macro to finish. Then use “decrease decimal” button in “Number” command group to decrease decimal digits to two.Īnd then change the font styles and make it Bold Italic fonts using commands in “Font” command group.įinally, you can change the Fill color to Yellow and Font color to Red. Step 06: Apply the required formattings to the already selected cell.ĭo not click any cell after macro recording started. If you move the cursor on top of that, a tool tip appears saying “A macro is currently recording. If you look at the left side edge of the status bar located bottom of the excel window, there is a small solid square.

Now the “Record Macro” dialog box looks like this. May be it will be easy for you or someone else who uses the macros in this workbook later. This is not essential but if you like you can write a simple description to say what is this macro is about. Shall we keep it as “This workbook” for this example.įinally, you have the option to write a description for your macro. Next you have to select where to store the created macro. So when I want to run the macro I will just press the “Ctrl” + “n” keys from the keyboard.


In this case I will press just the “n” key. You can also press a key combined with shift key also. Put the cursor inside the input box and then press your preferred key to be the shortcut key to be combined with “Ctrl” key. This is actually the most important option for me as it allows you to run the macro by simply using this shortcut key. Next option is to assign a Shortcut key to your macro. So technically it does allow only single word names or identifiers just like variables and function name if you are familiar with them. It does not allow you to keep spaces or invalid characters like #, &”. You can give any valid name but should be started with a letter or an underscore (_). Step 05: Customize and Setup macro settings.įirst option is to give a unique name for your macro. Record macro dialog box offers you to customize the basic settings and options of the Macro. Wouldn’t you like if the Excel can remember what you want to do and repeat it by Excel itself for you when you told to do so? That is what a macro would do for you. If you just have two, three occurrences of this type of cells, you don’t have to worry much.īut if you have a dozens of cells to repeat this procedure, that will be really boring. Finally change the cell background color to Yellow.Then change font styles to “Bold Italic” with red color.Apply Number formatting to round them off to two decimal places.So assume that I want to apply following formattings. When I found numbers like 3.14159265359, 1.4121356 having lot of decimal digits in Excel cells I want to apply few formattings to look them cleaner and more readable.
#HOW TO WRITE A MACRO IN EXCEL 2013 CODE#
Alternatively, we can write macros with visual basic for application code on Excel.

The easiest method to create a macro in excel is to use the “Record Macro” feature. You can easily create a macro in excel by using Excel Macro Recorder or by writing macros with visual basic for applications code on excel.
