简体   繁体   中英

Excel VBA - How to know if the next row or column is tha last one?

Hello,

What is the VBA code to know if the Excel's row or column is the last one? I mean if the cursor is in the 65,536's row and there is no more rows, how to know there will be know more rows? This can be easily done by a if else condition by entering the last row number (65,536). However, my VBA code to needs to work on Excel 2003-2013. The maximum rows numbers differ from different version.

My program will be entering data until the last row. If the next row is the last one, then how to detect it through VBA code? Also for last column?

Try using this...

MsgBox ActiveSheet.Rows.Count 'It will give no of Rows of Active Sheet

MsgBox ActiveSheet.Columns.Count ' It will give no of Columns of Active Sheet

MsgBox ActiveSheet.Cells.Count ' It will give Total no of Cells of Active Sheet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM