sub test()
dim rng as range
dim rw as integer
dim col as integer
set rng = Range("A1").CurrentRegion 'choose the top leftmost cell in the range
rw = rng.rows.count 'counts the number of rows in the selection
col = rng.columns.count 'counts the number of columns
rng.select 'selects the range in an efficient manner
rng.columns(2).select 'selects the second column in the range
rng.rows(2).select 'selects the second row in the range
rng.cells(1,2).select 'selects the cell on the first row and second column in the range
end sub
1 回答
使用相对参考肯定会得到正确的编码 . 或者您可以将此代码
Range("A1").CurrentRegion.Select
放入宏中的适当位置(将最左上角的单元格放在"A1"的位置) .如果要进行更高级的工作,可以将当前区域保存为变量,并使用不同的属性来执行除简单选择区域之外的其他操作 .
例如:
希望这很有帮助 . 我只是想扩展一些你可以做的事情来处理你拥有的范围 .