Select or Copy 3 non-adjacent cells

醉酒当歌 提交于 2019-12-10 14:49:08

问题


How can I copy 3 non-adjacent cells using ActiveCell.Row?

Range("A" & ActiveCell.Row, "C" & ActiveCell.Row, "E" & ActiveCell.Row).Copy

回答1:


To simplify things a little:

Range(Replace("A?,C?,E?", "?", ActiveCell.Row)).Copy



回答2:


You have the , outside the "". You need to put them inside. See this

Range("A" & ActiveCell.Row & ",C" & ActiveCell.Row & ",E" & ActiveCell.Row).Copy



回答3:


Try this:

Union(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 3), Cells(ActiveCell.Row, 5)).Copy



回答4:


I think there is tons of way to do this, you might read this it will give you better insight.

I would have done :

Sub test()

Set x = Application.Union(Range("A" & ActiveCell.Row), Range("C" & ActiveCell.Row), Range("E" & ActiveCell.Row))
x.Copy

End Sub


来源:https://stackoverflow.com/questions/58075423/select-or-copy-3-non-adjacent-cells

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