Situatie
A macro is a code written in VBA (Visual Basic for Applications) that allows you to run a chunk of code whenever it is executed. When you record a macro, Excel closely watches the steps you’re taking and notes it down in a language that it understands – which is VBA.
And since Excel is a really good note taker, it creates a very detailed code (as we will see later in this tutorial). Now, when you stop the recording, save the macro, and run it, Excel simply goes back to the VBA code it generated and follows the exact same steps.
Solutie
Pasi de urmat
If you can already see the developer tab in the ribbon, go to the next section, else follow the below steps:
- Right-click on any of the existing tabs in the ribbon and click on ‘Customize the Ribbon’ option. It will open the Excel Options dialogue box.
In the Excel Options dialogue box, you will have the Customize the Ribbon options. On the right, within the Main Tabs pane, check the Developer option.
The above steps would make the Developer tab available in the ribbon area.
Here are the steps to record this macro:
- Click the Developer tab.
- In the Code group, click on the Macro button. This will open the ‘Record Macro’ dialog box.
- In the Record Macro dialog box, enter a name for your macro. I am using the name EnterText. There are some naming conditions that you need to follow when naming a macro. For example, you can not use spaces in between. I usually prefer to keep my macro names as a single word, with different parts with a capitalized first alphabet. You can also use underscore to separate two words – such as Enter_Text.
In the ‘Store macro in’ option, make sure ‘This Workbook’ is selected. This step ensures that the macro is a part of the workbook. It will be there when you save it and reopen again, or even if you share it with someone.
- Optional Step) Enter a description. I usually don’t do this, but if you’re extremely organized, you may want to add what the macro is about.
- Click OK. As soon as you click OK, it starts to record your actions in Excel. You can see the ‘Stop recording’ button in the Developer tab, which indicates that the macro recording is in progress.
- Select cell A2.
- Enter the text Excel (or you can use your name).
- Hit the Enter key. This will select cell A3.
- Click on the Stop Recording button the Developer tab.
Leave A Comment?