How to Insert and Run VBA Code in Excel?

In Excel VBA stands for (Visual Basic for Application Code) where we can automate our task with help of codes and codes that will manipulate(like inserting, creating, or deleting a row, column, or graph) the data in a worksheet or workbook. With the help of VBA, we can also automate the task in excel to perform all these tasks we need to insert and run the VBA code properly which we will discuss in this article. 

Steps to Insert and Run VBA Code in Excel

To use the VBA code properly in Excel we need to change the default macro security settings of excel for that we need to follow further steps

Step 1: Click on the “File” menu at the left top of the excel tab. 

 

Step 2: Select “Options” to get the “Excel Options” window.

 

Step 3: Select “Customized Ribbon” in the “Excel Options” Window and then select the “Developer” check box in the “Main Tabs”.

 

Step 4: Then return to the main Excel window to select the “Developer” ribbon and then click on “Macro Security” in the “Code” group.

 

Step 5: Click on “Macro Settings” to select “Disable all macros except digitally signed macros”.

 

Now, to insert and run the VBA in Excel so that we can write codes we need to follow further steps:

Step 1: In the main Excel window press “Alt + F11” to open Visual Basic Editor

 

Step 2: Select “Sheet1(Sheet1)” in the “Project – VBAProject” tab.

 

Then we will get a terminal where we can write the following code,

 

Step 4: After writing a piece of code according to the user’s need  we need to press “F5” to run the code and then click on “Run” in the “Macro” Tab

 

Then, the output of the code will be seen in the Excel sheet.