【问题标题】:Error when pasting values using macro使用宏粘贴值时出错
【发布时间】:2017-03-05 21:02:35
【问题描述】:

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

请检查我的代码如下:

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。

请指教。

谢谢。

【问题讨论】:

    标签: vba excel excel-formula excel-2013


    【解决方案1】:

    你用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
    

    希望我能帮上忙。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      相关资源
      最近更新 更多