VBA-使用数字选择列? [英] VBA - Select columns using numbers?
本文介绍了VBA-使用数字选择列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找此 code
的替代方法,但要使用数字.我想选择5列,开始列是一个变量,然后从中选择5列.
I'm looking for an alternative to this code
, but using numbers.
I want to select 5 columns, the start column is a variable, and then it selects 5 columns from this.
Columns("A:E").Select
如何改为使用 integers
来引用列?像下面这样?
How do I use integers
instead, to reference columns? Something like below?
For n = 1 to 5
Columns("n : n + 4") .select
do sth
next n
谢谢.宝石
推荐答案
您可以像这样使用调整大小:
You can use resize like this:
For n = 1 To 5
Columns(n).Resize(, 5).Select
'~~> rest of your code
Next
在执行的任何范围操作中,请始终紧记调整大小和偏移量属性.
In any Range Manipulation that you do, always keep at the back of your mind Resize and Offset property.
这篇关于VBA-使用数字选择列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文