从范围variables中查找第一行和最后一行数字

我有一些代码,我正在与excel范围保存在variables中。 我需要一种方法来查找这些范围variables的第一行和最后一行。 如果可能,我宁愿不使用xlend(down).row方法。 我想我可以把它放到一个数组中,并获取lbound和ubound的值,但是对于一个非常简单的任务来说,这看起来像很多工作。 任何简单的解决scheme的问题?

这就是我所举的例子:

 sub test() dim r as range dim x as integer dim y as integer set r as worksheets("sheet1").Range("A1:A7") x = r.rows 'this gets me the first row in the range y = r.lastrow 'this isn't valid, but I need something that will do the equivalent of this pseudo code end sub 

你可以使用这个

 y = r.rows.count + x -1