Insert column

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I would like a macro to insert a new column to the left of the selected cell but copy all the formulas and formats from column E
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
step 1---If you want a macro, if this is something that will be repeated over and over again and in the same format, click on the developer tab and select "record macro". Then go through the steps to record the macro and save it...it should walk you through the steps to do this.

step 2---First insert a column where you will put your data. then highlight column E and right click copy. Then highlight where you want to place the column and right click and do a paste special and choose formulas and number formats.

If this is a one time thing then just follow step 2 above
 
Upvote 0
Hi,

I tried this before but it uses the specific cell references for where to insert the row and then when to paste the data from column E, the insert column could be on any column so the code needs to move to the selected cell.
 
Upvote 0
Post the code that you got from the Recorder. It should be easy to change it to peg it to ActiveCell rather than a fixed column.
 
Upvote 0
Code:
Sub Insert()
    Columns("L:L").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Columns("E:E").Select
    Selection.Copy
    Columns("L:L").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False
    Range("L1").Select
    Application.CutCopyMode = False
End Sub
 
Upvote 0
Try

Code:
Sub NewCol()
Columns("E").Copy
ActiveCell.Offset(, -1).EntireColumn.Insert
With Cells(1, ActiveCell.Column - 1)
    .PasteSpecial Paste:=xlPasteFormulas
    .PasteSpecial Paste:=xlPasteFormats
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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