VBA How to copy the content of a cell without .Select

只谈情不闲聊 提交于 2020-01-22 11:42:08

问题


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?

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 question not to use it whenever possible. What can I do?

' Created by the Macro Recorder
Range("A28:A33").Select
Range("A33").Activate
Selection.Copy
Sheets("Label").Select
Range("A1").Select
ActiveSheet.Paste

回答1:


Worksheets("Get Address").Range("A33").Copy _
       Destination := Worksheets("Label").Range("A1")



回答2:


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



来源:https://stackoverflow.com/questions/16698644/vba-how-to-copy-the-content-of-a-cell-without-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!