Let's say I have an excel document and I'm trying to get the range where the rows have values in their cells. (I'm using C# and interop).
excel.Application appExcel = new excel.Application();
excel.Workbook WbExcel;
excel.Worksheet sheet;
WbExcel = appExcel.Workbooks.Open(path);
sheet = WbExcel.Sheets["Sheet1"];
sheet.Activate();
excel.Range selectedRange = sheet.Range["A4", sheet.UsedRange.SpecialCells(excel.XlCellType.xlCellTypeLastCell)];
appExcel.Visible = true;
The problem comes when some rows are formatted but without values in their cells or some cell had a value before, they are selected too!.
I tried selecting only visible values:
selectedRange.SpecialCells(excel.XlCellType.xlCellTypeVisible).Select();
but it did not work.
Does anyone have a sugestion how could I make a range, avoiding rows with empty values in their cells or empty formatted cells?