如何找到最后一行包含数据在Excel表格与宏? [英] How can I find last row that contains data in the Excel sheet with a macro?
本文介绍了如何找到最后一行包含数据在Excel表格与宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何找到包含特定列和特定工作表中数据的最后一行?
How can I find the last row that contains data in a specific column and on a specific sheet?
推荐答案
:
Sub GetLastRow(strSheet, strColumn)
Dim MyRange As Range
Dim lngLastRow As Long
Set MyRange = Worksheets(strSheet).Range(strColum & "1")
lngLastRow = Cells(Rows.Count, MyRange.Column).End(xlUp).Row
End Sub
重新评论
这个
Cells.Find("*",SearchOrder:=xlByRows,SearchDirection:=xlPrevious).Row
即使最后一行中只有一个单元格具有数据,也会返回最后一个单元格的行号。
Will return the row number of the last cell even when only a single cell in the last row has data.
这篇关于如何找到最后一行包含数据在Excel表格与宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文