Insert Multiple Columns Using Macros (VBA) in Excel Office 365!!
Tags: insertmultiplecolumn, vbamacros
Published: 2020-09-28 07:59:19

---
title: Insert Multiple Columns Using Macros (VBA) in Excel Office 365!!
published: true
date: 2020-09-28 07:10:23 UTC
tags: InsertMultipleColumn,VBAMacros
canonical_url: https://geekexcel.com/insert-multiple-columns-using-macros-vba-in-excel-office-365/
---

## Insert Multiple Columns Using Macros (VBA) in Excel:

In this tutorial, we will guide you to learn the steps to **Insert Multiple Columns Using Macros (VBA) in Exce**l Office 365 with an example. Get an official version of **MS Excel** from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)
## **Steps to**  **Insert Multiple Columns Using Macros:**

To insert multiple columns in Excel using Macros, follow the below steps.

- On the **Developer**  **Tab** , **select** the **Visual**  **Basic** option under the code section.

![Select Visual Basic option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Select-Visual-Basic-option-1.png)<figcaption id="caption-attachment-14665">Select Visual Basic option</figcaption>

- Now, you need to make sure that the sheet1 is selected. Then, enter the below code.

VBA code for inserting multiple columns

Sub InsertMultipleColumns()

Dim numColumns As Integer

Dim counter As Integer

‘You need to select the current column

ActiveCell.EntireColumn.Select

On Error GoTo Last

numColumns = InputBox(“Enter number of columns to insert”, “Insert Columns”)

‘You need to keep on insert columns until we reach the desired number

For counter = 1 To numColumns

Selection.Insert Shift:=xlToRight, CopyOrgin:=xlFormatFromRightorAbove

Next counter

Last: Exit Sub

End Sub

- You need to save the code by selecting it. Then close the window.

![Enter the source code](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/1-105.png)<figcaption id="caption-attachment-14674">Enter the source code</figcaption>

- You need to select any cell where you want to insert columns. Then, go to the **Developer**  **Tab** , **choose** the **Macros** option.

![Choose Macros option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Choose-Macros-option.png)<figcaption id="caption-attachment-14667">Choose Macros option</figcaption>

- You have to make sure that your Macro is selected and **click** the **Run** button.

![Macro dialog box](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Macro-dialog-box-1.png)<figcaption id="caption-attachment-14675">Macro dialog box</figcaption>

- It will open the **Insert Columns dialog**  **box** , you have to **enter the number of columns** that you need to add in the text box. Then, hit the **OK** button.

![Insert Columns dialog box](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Insert-Columns-dialog-box.png)<figcaption id="caption-attachment-14676">Insert Columns dialog box</figcaption>

- Now, the specified number of columns will be added to the spreadsheet.

![Result](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Result-8.png)<figcaption id="caption-attachment-14677">Result</figcaption>

## **Summary:**

In this tutorial, we guided you to learn the steps to **Insert Multiple Columns Using Macros (VBA) in Exce**l Office 365 with an example. Give your **suggestions** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!!