![](/img/trans.png)
[英]How to copy and paste a column of dynamic data (as values) to another column in VBA?
[英]VBA Copy Column and Paste Values to Last Unmodified Column
ABCDE
zx c
zx c
zx c
至
ABCDE
zx cz
zx cz
zx cz
所以我想选择一列,宏将其移到E列
当前尝试定义了一个范围,因此该范围在不同的工作簿之间不可用。
当您说“移至E列”时,我想您的意思是“复制至E列”。 请在下面尝试此代码
Sub Copy_Col()
Dim lc As Long
With ActiveSheet
lc = .Cells(1, .Columns.Count).End(xlToLeft).Column
Selection.Copy
.Cells(1, lc + 1).PasteSpecial
.Range("A1").Select
End With
Application.CutCopyMode = False
End Sub
谢谢
卡里科
Option explicit
Sub CopyColumn()
Dim LastUnmodifiedColumn as long
' no qualified workbook/worksheet below. Therefore, implicitly refers to whatever book/sheet is active'
Lastunmodifiedcolumn = cells(1, columns.count).end(xltoleft).column + 1
' if you want values only, can assign values directly without using clipboard copy/paste operations'
With selection
.value2 = .offset(0,lastunmodifiedcolumn - .column).value2
'If you want to move and not copy, uncomment next line.'
'.clearcontents
End with
End sub
希望它有用或有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.