Posts

Showing posts from January 28, 2019

Insert specified number of columns between two named columns

Image
2 I am trying to use VBA to insert a set number of columns between two preexisting and defined ones. However, it keeps inserting the new columns to the left of the range. I want to insert the columns within the range. Here's my VBA code to provide some context: Sub InsertNewColummnbetween() Range(Range("Data_FirstColumn").Offset(, 1), Range("Data_Net").Offset(,2)).EntireColumn. Application.DisplayAlerts = False Dim i As Integer For i = 1 To Range("Assumptions!B26").Value Columns(1).INSERT Next i Application.DisplayAlerts = True End Sub What is wrong with my commands? microsoft-excel microsoft-excel-2010 vba share | improve this question ...