我正在尝试创建一个新列,并且只能创建一个新列而不能插入值。我的目标是将Sheet1的C列插入Sheet2的B列中以获得Sheet3的结果。
Sheet1:
Sheet2:
Sheet3:
这是我到目前为止尝试过的:
Sub AddColumn(length As Integer)
Dim cell As String
Dim form As String
Worksheets("Sheet2").Activate
Dim i, lastColumnNbr As Long
Dim lastColumnStr As String
lastColumnNbr = Worksheets("Sheet2").UsedRange.Columns.Count + 1
lastColumnStr = ColLetter(lastColumnNbr)
ColumnName = Split(base, " ")
Range(lastColumnStr & 1) = ColumnName(1)
Application.CutCopyMode = False
For i = 2 To length
cell = lastColumnStr & i
form = "=TEXT("B"&i,"m/d/yyyy")"
Range(cell).Formula = form
Next
Columns("A:A").Select
Application.CutCopyMode = False
Selection.Copy
Columns(LastColumnNbr).Select
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
提前谢谢