Question

I'm trying to fill an Excel 2010 cell programatically via COM Interop, with a string that represents an IF-formula.

The following line of code works just fine, it resolves to value 4 in Excel:

 .Range("C10").Value = "=2+2"

but when I pass an IF-Formula (as String)...

 .Range("C11").Value = "=IF(1+1=2;2;0)"

...I run into a COMException, saying: Exception from HRESULT: 0x800A03EC.

If I enter the same IF-formula directly in Excel, it is parsed correctly.

Thanks for your help!

Chris

Was it helpful?

Solution

You should replace the semicolons with commas and use .Formula instead .Value

.Range("C11").Formula= "=IF(1+1=2,2,0)"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top