Use macro to insert new column after every 4th column

crawftw

New Member
Joined
Sep 13, 2011
Messages
1
Hello,
I realize that this is probably a topic that has been discussed before, but I couldn't find an answer that worked for me from prior topics.

I have an excel spreadsheet with a large amount of employee data. About 150 employees are listed across the columns along the top, with four columns of information for each employee. I need to insert a 5th column after the original four for each employee, and I realize that the easiest, most efficient way to do this would be by way of a macro. I'm not good with all of the programing/code, and when I try to use the "record" feature in 07, it is simply inserting a new column in the same place every time.

Specifically, I have inserted a new column after the 4th cell of employee#16 and it is column CE. Starting there, I click record, select column CJ, and then click insert. The macro that recorded is as follows:

Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+z
'
Columns("CJ:CJ").Select
Selection.Insert Shift:=xlToRight
End Sub

Obviously this is not the correct macro. Does anyone know how I can do this?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this:-
Code:
Dim Last As Integer, Ac As Integer
Last = Cells("1", Columns.Count).End(xlToLeft).Column
    For Ac = Last To 1 Step -4
        Columns(Ac).Offset(, -3).EntireColumn.Insert
    Next Ac
Mick
 
Upvote 0

Forum statistics

Threads
1,215,016
Messages
6,122,700
Members
449,092
Latest member
snoom82

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