另一种尝试的方法。当您将初始列设置为 Range 对象时,也select
可以替换。性能方面它有帮助。
Dim rng as Range
Set rng = WorkSheets(1).Range("A1") '-- you may change the sheet name according to yours.
'-- here is your loop
i = 1
Do
'-- do something: e.g. show the address of the column that you are currently in
Msgbox rng.offset(0,i).Address
i = i + 1
Loop Until i > 10
** 使用列号获取列名的两种方法**
代码
colName = Split(Range.Offset(0,i).Address, "$")(1)
代码
Function myColName(colNum as Long) as String
myColName = Left(Range(0, colNum).Address(False, False), _
1 - (colNum > 10))
End Function