function nextRow = GoToNextRowInColumn(Excel, column)
try
cellReference = sprintf('%s1048576', column);
Excel.Range(cellReference).Select;
currentCell = Excel.Selection;
bottomCell = currentCell.End(3);
bottomRow = bottomCell.Row;
cellReference = sprintf('%s%d', column, bottomRow);
Excel.Range(cellReference).Select;
bottomCell = Excel.Selection;
bottomRow = bottomCell.Row;
cellContents = Excel.ActiveCell.Value;
if isnan(cellContents)
nextRow = bottomRow;
else
nextRow = bottomRow + 1;
end
catch ME
errorMessage = sprintf('Error in function GoToNextRowInColumn.\n\nError Message:\n%s', ME.message);
fprintf('%s\n', errorMessage);
WarnUser(errorMessage);
end
return;
end
Best Answer