如何用数据计算excel中的行数? [英] How to count the number of rows in excel with data?

查看:18
本文介绍了如何用数据计算excel中的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A 列有这样的数据(即频繁出现的空白单元格):

column A has data like this (ie frequent blank cells):

HEADING  <-- this is A1
kfdsl
fdjgnm
fdkj

gdfkj
4353

fdjk  <-- this is A9

我希望能够获取具有数据的最后一个单元格的单元格引用.所以在上面的例子中,我想返回:A9

I would like to be able to get the cell reference of the last cell that has data. So in the above example, I want to return: A9

我试过了,但它停在第一个空白单元格(即返回A4)

I have tried this but it stops at the first blank cell (ie returning A4)

numofrows = destsheet.Range("A2").End(xlDown).Row - 1

推荐答案

我喜欢这种方式:

ActiveSheet.UsedRange.Rows.Count

同样可以用列数来完成.对我来说,永远工作.但是,如果您在另一列中有数据,则上面的代码也会考虑它们,因为该代码正在查找工作表中的所有单元格区域.

The same can be done with columns count. For me, always work. But, if you have data in another column, the code above will consider them too, because the code is looking for all cell range in the sheet.

这篇关于如何用数据计算excel中的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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