Step 1: Enable the Developer tab in the Ribbon.
By default the Developer tab is hidden and you will need to enable it to use in the ribbon.
Step 2: Open the visual basic editor.
Now you should see the Developer tab in your Excel ribbon and you can open the visual basic editor (VBE) from the ribbon. Alternatively, you can open the VBE with the Alt + F11 shortcut.
Step 3: Insert a module into the current workbook.
On the left hand side of the VBE you should see the Project Explorer side bar. This will list all your open workbooks and VBE objects associated with them. If you don’t see the project explorer, go to View > Project Explorer or press Ctrl + R.
A new item will appear in the project explorer called Module1 and the previously grey space will contain a white section. This is the module code window.
Step 4: Run your code.
Now you can run your code. Alternatively, to open the Macro window you can use the Alt + F8 shortcut.
Note: For saving your workbook.
You will need to save your workbook as a macro-enabled file type if you want to use this code the next time you open the workbook. These file types all support macros (VBA).