This project has moved. For the latest updates, please go here.

Adding a COUNTIF formula to a cell that counts text values causes spreadsheet not to work

Jan 21, 2013 at 4:47 PM
Edited Jan 21, 2013 at 6:25 PM

I have a simple table where one column is a name and the second column is a value. I want to count the number of rows on another sheet with the same name. When I attempt to set this formula, it appears to work but when I try to open the spreadsheet that is saved, it closes before I can see it. If I comment out the formula line, the code works fine. Has anyone encountered this issue before?  



string sName = Convert.ToChar(34) + sNames[i] + Convert.ToChar(34);                    
wSheet.Cells[4 + i, 2].Value = sNames[i];                   
wSheet.Cells[4 + i, 3].Formula = string.Format("COUNTIF('YTD Detail'!K:K|" + sName  + ")");
Jan 22, 2013 at 1:23 PM

The problem is the "pipe" symbol in the COUNTIF. 

"COUNTIF('YTD Detail'!K:K|" + sName  + ")"