vba 选中最后最后一个有值的列的下一列黏贴
时间: 2024-05-29 21:12:36 浏览: 252
Sub PasteAfterLastColumn()
Dim lastCol As Long
Dim pasteCol As Long
Dim pasteRange As Range
'获取最后一个有值的列
lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
'设置黏贴的列为最后一个有值的列的下一列
pasteCol = lastCol + 1
'定义黏贴的区域
Set pasteRange = Range(Cells(1, pasteCol), Cells(Rows.Count, pasteCol))
'在黏贴区域中黏贴内容
pasteRange.PasteSpecial xlPasteAll
End Sub
阅读全文
相关推荐










