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:這是找到拉斯特羅的不正確方法。 –