0
可能重复:
How can I find last row that contains data in the excel sheet with a macro?
Error Finding Last Used cell In VBA获取包含数据的最小/最大行号的行号?
如果我有一个电子表格,其中有数据为10434的最大行数是存在的,这将给我行号10434的功能?
谢谢
可能重复:
How can I find last row that contains data in the excel sheet with a macro?
Error Finding Last Used cell In VBA获取包含数据的最小/最大行号的行号?
如果我有一个电子表格,其中有数据为10434的最大行数是存在的,这将给我行号10434的功能?
谢谢
Sub largestrow() Dim largestrowNum As Long Dim col As Integer For col = 1 To Columns.Count lastrow = Application.WorksheetFunction.Max(Cells(65536, col).End(xlUp).Row, largestrowNum) Next col MsgBox "Largest row number =" & largestrowNum End Sub
(将工作,只要您有少于65536行)
此代码使用xl2003的65536行限制。更强大的版本是“Cells(Rows.Count,col)”。但是在这个例子中,这仍然是空白列的失败 – brettdj
这个问题不看所关乎除非我是usedrange后? – mezamorphic
你在寻找有数据的最后一行吗? –
@Remou:这是找到拉斯特罗的不正确方法。 –