Handling "No cells were found." Error in Excel
- by Sathish
I am working on Excel VSTO application and finding error cells in the worksheets using the below code
Excel.Range rngTemp;
Excel.Range rngErrorRange;
Excel._Worksheet Sheet1 = (Excel._Worksheet)xlCTA.Sheets["Sheet1"];
rngTemp = wsCTAWK11.UsedRange;
rngErrorRange = rngTemp.SpecialCells(Excel.XlCellType.xlCellTypeFormulas, Excel.XlSpecialCellsValue.xlErrors);
when there are really error cells found then i do not have any issues but when i dont have any error cells in these sheet i get the below exception
**threw an exception of type 'System.Runtime.InteropServices.COMException'
base {System.Runtime.InteropServices.ExternalException}: {"No cells were found."}**
How to handle this... Pls help