#How to delete certain rows in excel vba code#
We will use the following code for the active cell. Assume we are on cell B3 and want to insert the cell above it we will use active cell property. Example #3 – Using Active CellĪctive cell means the cell that is presently selected. Similarly, we can customize our function to insert as many rows as we can. When we click on the button “Insert 2 Rows” we see that 2 rows have been inserted in between 3 rd and 4 th row. In this, we need to mention row from start row to end row number using RANGE followed by INSERT which will insert the rows. Similarly, we will write a code to insert 2 rows on a click of a button. Step 7: Run the code by clicking on the Insert 3 Rows Command Button.
![how to delete certain rows in excel vba how to delete certain rows in excel vba](https://excel.officetuts.net/wp-content/uploads/sites/2/2018/10/delete-rows-example.png)
In the above line of code, A3 is a column where we have to insert row and Rows(3:5) is we have to insert 3 new rows. As mentioned previously we have to use Rows.EntireRow function with RANGE in VBA. In this code, we have to insert 3 between 3 rd and 4 th. Step 6: We have to write our code of INSERT ROW.
![how to delete certain rows in excel vba how to delete certain rows in excel vba](https://www.excelhow.net/wp-content/uploads/2020/03/Delete-Rows-Under-Certain-Row-1.png)
Step 5: When you click on the View code, the following code appears. Step 4: To enter the Insert function Right-click on the Comand Button i.e. Insert 3 Rows and click on View Code. Step 3: Drag the arrow at any cell to create a Command Button.
![how to delete certain rows in excel vba how to delete certain rows in excel vba](https://img.chandoo.org/q/delete-blank-rows-excel.png)
Click on Insert and select the first option from ActiveX Controls. Step 2: After the Developer tab opens, insert a button from the Controls group. Step 1: To create a Macro we need to select the Developer Tab.
#How to delete certain rows in excel vba download#
You can download this VBA Insert Row Excel Template here – VBA Insert Row Excel Template Example #1 – Using Entire Rowįollow the below steps to insert Rows in excel using VBA code.