vba VBA如何在没有.Select的情况下复制单元格的内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16698644/
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
VBA How to copy the content of a cell without .Select
提问by George
I am writing a method that can take the Target
and paste the cell exactly to another cell. The cell is a shipping label with some fancy formating. Is there a way I can do it?
我正在编写一种可以Target
将单元格准确粘贴到另一个单元格的方法。单元格是带有一些奇特格式的运输标签。有什么办法可以做到吗?
Originally I have this:
原来我有这个:
Worksheets("Label").Range("A1").Value = Worksheets("Get Address").Range("A28").Value
It worked for the plain text. However I lost the styling I created, they are different because after the first line, the style is different:
它适用于纯文本。但是我丢失了我创建的样式,它们是不同的,因为在第一行之后,样式是不同的:
I also tried to use Macro Recorder and I got a solution using .Select
, and I read this questionnot to use it whenever possible. What can I do?
我也尝试使用宏记录器,我得到了一个解决方案.Select
,我读了这个问题,尽可能不要使用它。我能做什么?
' Created by the Macro Recorder
Range("A28:A33").Select
Range("A33").Activate
Selection.Copy
Sheets("Label").Select
Range("A1").Select
ActiveSheet.Paste
回答by Tim Williams
Worksheets("Get Address").Range("A33").Copy _
Destination := Worksheets("Label").Range("A1")
回答by sai baba
to copy and paste values only then use following
仅复制和粘贴值然后使用以下内容
Worksheets("Label").Range("A1").value = _
Worksheets("Get Address").Range("A33").value
this statement will not use clip board
此声明将不使用剪贴板