简体   繁体   English

range.cells.copy到vba中的range.cells.paste

[英]range.cells.copy to range.cells.paste in vba

Hi I am trying to copy a set on cells from the last filled column of a particular row to the next column . 您好我正在尝试将特定行的最后一个填充列上的单元格复制到下一列。 I am not getting any error but the values are not getting pasted. 我没有收到任何错误,但值没有被粘贴。

my code : 我的代码:

Dim ed As Variant Dim ee As Variant Dim ed As Variant Dim ee As Variant

  ed = ActiveSheet.Cells(55, Columns.count).End(xlToLeft).Column
  ee = ActiveSheet.Cells(55, Columns.count).End(xlToLeft).Column + 1

ActiveSheet.Range(ActiveSheet.Cells(ed, 55), ActiveSheet.Cells(ed, 68)).Copy ActiveSheet.Range(ActiveSheet.Cells(ee, 55), ActiveSheet.Cells(ee, 68))
Application.CutCopyMode = False

You've transposed row and column in your copy statement. 您已在副本语句中转换了行和列。

Instead of ActiveSheet.Range(ActiveSheet.Cells(ed, 55), ActiveSheet.Cells(ed, 68)).Copy ActiveSheet.Range(ActiveSheet.Cells(ee, 55), ActiveSheet.Cells(ee, 68)) try: 而不是ActiveSheet.Range(ActiveSheet.Cells(ed, 55), ActiveSheet.Cells(ed, 68)).Copy ActiveSheet.Range(ActiveSheet.Cells(ee, 55), ActiveSheet.Cells(ee, 68))试试:

ActiveSheet.Range(ActiveSheet.Cells(55,ed), ActiveSheet.Cells(68, ed)).Copy ActiveSheet.Range(ActiveSheet.Cells(55, ee), ActiveSheet.Cells(68, ee))

But there are a number of better ways to achieve this range copy. 但是有很多更好的方法来实现这个范围副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM