Excel Macro Insert Column tutorial

posted in: Uncategorized | 0

Excel Macro Insert Column tutorial

excel tutorials for dummies

If you are new to editing Macro or VBA code for your own projects and purposes then please read this guide to help you alter the code below for your own purposes before you proceed.

In this guide we will outline how you can write an Excel Macro which will insert a new column into your spreadsheet at a location you define. In this guide we use VBA code to achieve our objective which we will term “Insert Column VBA”. This can be found in more detail. This VBA code will add columns in Excel every time it is executed and can be used in a multitude of different ways and workbook projects.

The video below also outlines how this is achieved from our YouTube channel so please feel free to check this out which will supplement this tutorial.

Excel VBA Column Tutorial video

 

In this example the code that we used is as follows:

Insert Column VBA

 

 

Private Sub CommandButton1_Click()

Sheets(“Sheet1”).Range(“D4”).Select

ActiveCell.EntireColumn.Insert shift:=xlDown

End Sub

You will need to edit the “Insert Column VBA” code for your own purposes, this will possibly include renaming the Sheet and Range. For instance if your sheet had been renamed to “Customer” and where you wanted to add a new column was B4, your first line of code would appear as follows.

Sheets(“Customer”).Range(“B4”).Select

This tutorial should have hopefully outlined how to add columns in Excel using an Excel Macro. Please visit the YouTube channel for more tutorials.

Leave a Reply