确定范围内的行数 [英] Determine the number of rows in a range

查看:111
本文介绍了确定范围内的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道列表开头的范围名称 - 1 列宽, x 行深。 / p>

如何计算 x



列中的数据多于此列表。但是,这个列表是连续的 - 在上面或下面的任何一个单元格中都没有任何内容,或者旁边的任何一个单元格。

解决方案

 函数ListRowCount(ByVal FirstCellName as String)as Long 
With thisworkbook.Names(FirstCellName).RefersToRange
如果isempty(.Offset(1,0).value)Then
ListRowCount = 1
Else
ListRowCount = .End(xlDown).row - .row + 1
如果
结束
结束函数

但是如果你确定列表中没有任何内容,那么只需 thisworkbook.Names FirstCellName).RefersToRange.CurrentRegion.rows.count


I know the range name of the start of a list - 1 column wide and x rows deep.

How do I calculate x?

There is more data in the column than just this list. However, this list is contiguous - there is nothing in any of the cells above or below or either side beside it.

解决方案

Function ListRowCount(ByVal FirstCellName as String) as Long
    With thisworkbook.Names(FirstCellName).RefersToRange
        If isempty(.Offset(1,0).value) Then 
            ListRowCount = 1
        Else
            ListRowCount = .End(xlDown).row - .row + 1
        End If
    End With
End Function

But if you are damn sure there's nothing around the list, then just thisworkbook.Names(FirstCellName).RefersToRange.CurrentRegion.rows.count

这篇关于确定范围内的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆