person holding blue and clear ballpoint pen

How to Insert Row or Column in Excel VBA?

In this post, let’s have a look at examples in Excel VBA demonstrating how to insert row or column in your Microsoft Excel spreadsheet.

How to Insert Row or Column in Excel VBA?

How to Insert Row or Column in Excel VBA?

To insert rows or columns we can use the Insert Method in Excel.

Insert a Single Row

Insert New Row

To insert a single row, use this VBA code.

Code:

Rows(4).Insert

Insert Entire Row

To insert an entire row, use the below VBA code.

Code:

Range("b4").EntireRow.Insert

Insert New Column

To insert new column, use the below code snippet

Code:

Columns(4).Insert

Insert an Entire Column

To insert an EntireColumn in your excel worksheet, use the below code snippet.

Code:

Range("b4").EntireColumn.Insert

Insert Multiple Rows or Columns

Insert Multiple Rows

To insert multiple rows

Code:

Rows("4:6").Insert

Insert Multiple Columns

To insert Multiple Columns

Code:

Columns("B:D").Insert

Insert Rows Based on Cell Value

This will loop through a range, inserting rows based on cell values:

Sub InsertRowswithSpecificValue()

Dim cell As Range

For Each cell In Range("b2:b20")

    If cell.Value = "insert" Then

        cell.EntireRow.Insert

    End If

Next cell

End Sub

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn how to Find Blank cells in excel so that you can remove or delete the blank cells form...
In this article, you’ll learn what is a Gauge Chart in Microsoft Excel. Also, you will learn how to add...
Microsoft Excel provides a shortcut for the users to move columns in excel using two different ways – using Shift...