Hi, I have to delete some excel rows based on on cell value .I tried diffrent code and following too. But i get the error
"Cannot perform Run time binding on a null refference"
All delete method i am getting same error
for (int i = 2; i <= Rows; i++)
{
var DepDel1 = (Excel.Range)xlWorksheetNew.Cells[i, 9]; string DepDel = DepDel1.Value2.ToString();
Excel.Range r = xlWorksheetNew.Range[xlWorksheetNew.Cells[i, 1], xlWorksheetNew.Cells[i, 10]];
if (DepDel == "01") { // if match, delete and shift remaining cells up: r.EntireRow.Delete(XlDeleteShiftDirection.xlShiftUp); }
}