I ran in to the same error. For me it was while trying to set a CountIf and CountIfs respectively that I got the error.
After some trial an error I found out it was an issue I had with all formulas using multiple parameters.
It turns out that the parameter separator ";" (semicolon), which I use in excel is not the correct one for me to use in code behind. If I use "," (comma) in stead, the formula is correctly used.
Note: When viewed in Excel afterwards, it is shown as ";" (semicolon).
My trial and error process included trying to set a bunch of different formulas, and this was the 'fix' I ended up with.
I am running an English windows, but I am located in Denmark, I have no idea if there is some kind of localization involved with my issue.
CultureInfo.CurrentCulture.TextInfo.ListSeparator is ";", and this works correctly for separating validator rule values.
Perhaps this is the reason why my parameter separator is something else.
Anyways; the formula could be wrong because you need to use a different parameter separator character.
Microsoft.Office.Interop.Excel.Range neededRange = currentWS.Range[cell.Cells[1, 1], cell.Cells[nRowCount, nColumnCount]];
Here my rowcount is more than 66000. Column count is 18. Breaks on this function. – WeinerMicrosoft.Office.Interop.Excel.Range neededRange = currentWS.Range["A1", ((Microsoft.Office.Interop.Excel.Range)currentWS.Cells[nRowCount, nColumnCount])];
. But issue remains. – Weiner