使用VBA选择非相邻范围 [英] Using VBA to select non-adjacent range
本文介绍了使用VBA选择非相邻范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何选择范围,直到使用vba这样计算得出的最后一行:
I know how to select a range till a calculated last row using vba as such:
Range("P3:R" & LastRow).Select
是否有选择非相邻列数据的方法?例如,我希望单元格从N列到R WITHOUT 列O
Is there a way to select non-adjacent column data? For example I want cells from column N to R WITHOUT column O
下面尝试过,但最终还是选择了O,我怀疑是因为"
字符应该包含整个内容,但是我该如何保留最后一行的变量值?
Tried below, but it ends up selecting O too, I suspect because the "
character should encompass the whole thing, but then how do I keep the variable value for last row?
Range("N3:N" & LastRow , "P3:R" & LastRow).Select
谢谢!
推荐答案
You could use the Union method, not that you usually need to Select anything...
Union(Range("N3:N" & LastRow), Range("P3:R" & LastRow)).Select
这篇关于使用VBA选择非相邻范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文