Macro to insert columns between columns (modify yourselves)

Trader11

New Member
Joined
Feb 25, 2011
Messages
25
Hello,

I've read a dated thread with the same subject on the forum, but I thought posting a new one would be beneficial. As the recommended macros didn't work the way I wanted on my excel.

The macros were kind of tailor made and didn't allow me to edit them. When I changed the numbers to change the columns to be added, macro went crazy and added, some 8 columns, instead of adding 2, for example.

So what I ask is a macro that will allow me to insert as many columns as I want. But this time I'll appreciate if you can show which part of the macro to change if we want to insert 1 column or 3 columns etc. so everyone can modify accordingly.

Thank you.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi. Maybe like this

Code:
Sub InsCols()
Dim i As Long
i = Application.InputBox("How many columns?", Type:=1)
If i > 0 Then ActiveCell.Resize(, i).EntireColumn.Insert
End Sub
 
Upvote 0
Thanks.

When I run the macro a window opens allowing me to isnert a number, when I do so, the macro only adds that number of columns to the left of column A.

ps: I used both with and without quotation marks/
 
Upvote 0
Click in the column to the left of where you want to insert columns then run the macro. When prompted enter the number of columns (without quotes).
 
Upvote 0
Well I maybe expressed myself wrongly.

I have some hundred columns and I want to insert columns between all of them at the same time and at the sime size.

1 column to the left of all columns, for example.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top