0

I'm currently trying to use this to find the standard deviation of a range while also ignoring 0 values:

WS[stdCoord].value = '=STDEV(IF(' + range + '<>0,' + range + '))'

When I use a print statement to print out that specific cell.value the line before saving the workbook, it returns

=STDEV(IF(D2:D5<>0,D2:D5))

which is exactly what I want. However, when I open up the excel file, the cell gives me a #VALUE! error with its contents being

=STDEV(IF(@D2:D5<>0,D2:D5))

I have no clue where this "@" symbol is coming from and no one else seems to be getting this weird behavior.

I've tried hard coding the exact string that I want, but the "@" symbol still appears. Even tried putting in random spaces in the string. Any ideas?

  • You got Excel O365 most likely? In that case, don't use `.Value` but `.Formula2` and see if that fixes it? If not, we can re-open again. – JvdV Oct 01 '20 at 07:19
  • Is this specific to VBA? I tried using `WS[stdCoord].formula2`, but the cell object doesn't have a `formula2` attribute. I also don't know where the class `Cells` is coming from. I can't seem to find any documentation regarding this being implemented on openpyxl. Do you happen to have any links that I could have missed? – ther4nd0moo Oct 01 '20 at 16:07
  • Then use `.FormulaArray` – Scott Craner Oct 01 '20 at 22:42
  • I'm confused. What class is the `.FormulaArray` attribute from? cell objects don't have a `FormulaArray` attribute. – ther4nd0moo Oct 02 '20 at 01:06

0 Answers0