如何找到包含特定列中数据的最后一行? [英] How can I find last row that contains data in a specific column?

查看:115
本文介绍了如何找到包含特定列中数据的最后一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到特定列和特定工作表中包含数据的最后一行?

How can I find the last row that contains data in a specific column and on a specific sheet?

推荐答案

怎么样:

Function GetLastRow(strSheet, strColumn) As Long
    Dim MyRange As Range

    Set MyRange = Worksheets(strSheet).Range(strColumn & "1")
    GetLastRow = Cells(Rows.Count, MyRange.Column).End(xlUp).Row
End Function

关于注释,即使最后一行中只有一个单元格有数据,这也会返回最后一个单元格的行号:

Regarding a comment, this will return the row number of the last cell even when only a single cell in the last row has data:

Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

这篇关于如何找到包含特定列中数据的最后一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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