问题
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