Handling "No cells were found." Error in Excel
Posted
by Sathish
on Stack Overflow
See other posts from Stack Overflow
or by Sathish
Published on 2010-06-11T10:58:55Z
Indexed on
2010/06/11
11:02 UTC
Read the original article
Hit count: 947
c#
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
© Stack Overflow or respective owner