在 VBA 上同时使用 xlPasteValues 和 xlPasteFormats
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44154327/
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
xlPasteValues and xlPasteFormats at the same time on VBA
提问by Mertinc
I am copying a range and then pasting it's values and formats to another range as below:
我正在复制一个范围,然后将其值和格式粘贴到另一个范围,如下所示:
ws5.Range("F3:N" & xCell).SpecialCells(xlCellTypeVisible).Copy
ws16.Cells(Rows.Count, "B").End(xlUp).Offset(4, 0).PasteSpecial xlPasteValues
ws16.Cells(Rows.Count, "B").End(xlUp).Offset(4, 0).PasteSpecial xlPasteFormats
My question is, is it possible to do these two paste actions in one action without using With?I would like to increase the speed of my macro and that kind of small reductions might help me.
我的问题是,是否可以在不使用 With 的情况下在一个操作中完成这两个粘贴操作?我想提高我的宏的速度,这种小的减少可能对我有帮助。
Maybe there is something like .PasteSpecial xlPasteValues and xlPasteFormats
kind of solution that I don't know.
While I was searching for a solution for this question, I found that link but the only answer provided here is using With, which is useless for me.
也许有.PasteSpecial xlPasteValues and xlPasteFormats
我不知道的类似解决方案。当我为这个问题寻找解决方案时,我找到了那个链接,但这里提供的唯一答案是使用 With,这对我没用。
回答by jkpieterse
You are looking for:
您正在寻找:
xlPasteValuesAndNumberFormats
edit## This is not the correct answer.
编辑## 这不是正确的答案。
回答by MarredCheese
xlPasteAll
xlPasteAll
(Actually, since xlPasteAll
is the default paste option, you can just leave it off.)
(实际上,由于xlPasteAll
是默认粘贴选项,您可以将其关闭。)
Source: https://msdn.microsoft.com/en-us/library/aa195818(v=office.11).aspx
来源:https: //msdn.microsoft.com/en-us/library/aa195818(v=office.11).aspx
回答by user4375438
You can paste the content several times to get what you need, like
您可以多次粘贴内容以获得所需的内容,例如
Cells(1, 1).PasteSpecial Paste:=xlPasteAll
Cells(1, 1).PasteSpecial Paste:=xlPasteValues