If the application is your excel application, you can scroll through the lines starting at number 1 and look for the first empty one using the CountA function (it returns the number of non-empty cells for the range):
int rowIdx = 0; int notEmpty = 1; while (notEmpty > 0) { string aCellAddress = "A" + (++rowIdx).ToString(); Range row = App.get_Range(aCellAddress, aCellAddress).EntireRow; notEmpty = _App.WorksheetFunction.CountA(row); }
When the while loop exits, rowIdx is the index of the first empty row.
CountA receives 29 additional optional arguments, so itβs possible that you should pass Missing.Value 29 times with earlier versions of the framework.
source share