Codename K
Codename K

Reputation: 744

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?

Upvotes: 1

Views: 617

Answers (1)

Pallav Raj
Pallav Raj

Reputation: 1744

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

Upvotes: 5

Related Questions