It is similar to these two question:
Enter a new line and copy formula from cells above
excel vba insert row with formatting
I have seen this question, but I don't think it solves my problem.
It is similar to these two question:
Enter a new line and copy formula from cells above
excel vba insert row with formatting
I have seen this question, but I don't think it solves my problem.
Well, at least you have done some research, thus ... I will show about half of the answer - the format.
Take a look at the following:
Option Explicit
Public Sub CopyFormatToTheLeft(lngColumnNumber As Long)
If lngColumnNumber < 2 Then
MsgBox "Nope!"
Exit Sub
End If
Columns(lngColumnNumber).Copy
Columns(lngColumnNumber - 1).PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
Cells(1, 1).Select 'no selection - no fun
End Sub
Public Sub TestMe()
CopyFormatToTheLeft 3
End Sub
You will transfer the format of column C
to column B
. To transfer the formulas, take a look af the different posibilities of xlPaste
.
If you wanna insert this should do the trick, might not be the cleanest way ;) You can change the Offset
as you want.
Sub ColumnOffsetCopy()
Application.ScreenUpdating = False
Application.CutCopyMode = False
With ActiveSheet
ActiveCell.EntireColumn.Insert
ActiveCell.EntireColumn.Formula = ActiveCell.Offset(0, 1).EntireColumn.Formula
ActiveCell.Offset(0, 1).EntireColumn.Copy: ActiveCell.EntireColumn.PasteSpecial xlPasteFormats
End With
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
I just figure that I could insert column analogous to inserting rows. Following is the code for inserting the 15th column of destSheet:
Application.ScreenUpdating = False
Application.CutCopyMode = False
destSheet.Cells(1, 15).EntireColumn.Copy
Range(destSheet.Cells(1, 15).Offset(1, 0), destSheet.Cells(1, 15).Offset(1, 0)).EntireColumn.Insert Shift:=xlToLeft
Application.CutCopyMode = False
Application.ScreenUpdating = True