vba Excel VBA复制整个工作表并作为值过去

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47877443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 10:56:08  来源:igfitidea点击:

Excel VBA to copy entire sheet and past as values

excelexcel-vbavba

提问by user3496218

I am needing to create a VBA statement that will Copy the entire active sheet and then paste as values - seems pretty simple but I am not familiar with VBA - it would essentially be automating the 'click' in the top left and copy --> paste as values. here is what I am trying:

我需要创建一个 VBA 语句,该语句将复制整个活动工作表,然后粘贴为值 - 看起来很简单,但我不熟悉 VBA - 它本质上是自动化左上角的“点击”并复制 -->粘贴为值。这是我正在尝试的:

Sub CopyPasteSheetAsValues()
'Copy and Paste Summary Sheet as Values
Sheets("Summary Build").Cells.Copy
Sheets("Summary Build").Cells.PasteSpecial Paste:=xlPasteValue
End Sub

回答by cbasah

You miss an s in xlPasteValues. Also, good to add Application.CutCopyMode = False to avoid the marching ants around your copy area.

你错过了 xlPasteValues 中的一个 s。此外,最好添加 Application.CutCopyMode = False 以避免在您的复制区域周围行进蚂蚁。

Sub CopyPasteSheetAsValues()
    'Copy and Paste Summary Sheet as Values
    Sheets("Summary Build").Cells.Copy
    Sheets("Summary Build").Cells.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
End Sub