The better solution is to start at the bottom of the Excel worksheet and press End+Up. Now, this seems silly in the Excel interface because you can easily see whether you are really at the end of the data. But, because it is easy in Excel VBA to start at the last row, get in the habit of using this code to find the true last row.


Excel has had the same number of rows (65,536) since they increased it from 16,384 in 1995. Although it is very tempting and seemingly safe to hard code 65,536,1 firmly believe that we will finally see more rows in Excel 2005.To make your code work with any past or future version of Excel, some advocate using Rows.count as the number of rows in the currently open version of Excel. Using something along the lines of Cells(Row.Count,1).End(xlUp) ensures your code will work after we have more rows available in Excel. It also ensures your code will be compatible with pre-Excel 97 versions that have fewer than 65,536 rows.

0 0

Post a comment