使用宏粘贴值时出错

Error when pasting values using macro

为什么我下面的代码不能只粘贴值? 结果是粘贴公式而不是值。 有人可以帮忙吗?

请检查我的代码如下:

Sheets("Invoice Print").Activate Range("F21:F27").Select Selection.SpecialCells(xlCellTypeFormulas, 1).Select Selection.Copy Sheets("Outgoing Goods").Select Cells(Rows.Count, 1).Range("K1").End(xlUp).Offset(1, 0).Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False ActiveSheet.Paste Application.CutCopyMode = False

有没有错误?

PS: 我用的是 Excel 2013.

请指教

谢谢。

您在下一行用 ActiveSheet.Paste

覆盖粘贴的值

此外,您不应使用 .SelectSelection.

Sheets("Invoice Print").Range("F21:F27").SpecialCells(xlCellTypeFormulas, 1).Copy

With Sheets("Outgoing Goods")
.Cells(.Rows.Count, 1).Range("K1").End(xlUp).Offset(1, 0).PasteSpecial _
        Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False   

    'This line would overwrite the pasted values with not explecit values only
    'ActiveSheet.Paste
    Application.CutCopyMode = False
End With

希望能帮到你。