Hi All,
I am trying to get the last row in an excel sheet using C#.
The following code works for it.
int lastCount= wsht.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Row;
My problem is that when I delete rows using filter and then again use the above statement, the last count remains the same.
Where am I doing wrong??
What I have tried:
Here is how I add filter and remove cells:
wsht.Range[wsht.Cells[1, 1], wsht.Cells[lastRow, lastCol]].AutoFilter(12, "=Value to Delete", Excel.XlAutoFilterOperator.xlOr, Type.Missing, true);
xlapp.DisplayAlerts = false;
wsht.Range[wsht.Cells[2, 1], wsht.Cells[lastRow, lastCol]].SpecialCells(XlCellType.xlCellTypeVisible).Delete();
xlapp.DisplayAlerts = true;