I am using VBA to write formulas in an MS Excel sheet. When I copy the formula to the cell manually it works but when I use the line below it gives me a run-time error:
'1004': Application-defined or object-defined error.
ActiveSheet.Cells(Row + 3, Column + i).Formula = "=SUMPRODUCT(--(OFFSET(endResourceNaam;2;0):OFFSET(endResourceNaam;1000;0)=$A" & Row + 1 & ");--(OFFSET(endResourceNaam;2;4):OFFSET(endResourceNaam;1000;4)=$E" & Row + 1 & ");OFFSET(endResourceWeek;2;" & ColumnLetter(Column - 1) & "$1):OFFSET(endResourceWeek;1000;" & ColumnLetter(Column - 1) & "$1))"
The (first in loop) string generated is:
=SUMPRODUCT(--(OFFSET(endResourceNaam;2;0):OFFSET(endResourceNaam;1000;0)=$A6);--(OFFSET(endResourceNaam;2;4):OFFSET(endResourceNaam;1000;4)=$E6);OFFSET(endResourceWeek;2;O$1):OFFSET(endResourceWeek;1000;O$1))
I tested the formula by printing it from the VBA code and than copy/pasta that to the cell. That way I know for certain that the generated string is actually correct. From what I have learned there is some kind of protection build into VBA that makes sure that when I try to write a formula the formula is correct and working. There might be something in that protection that is keeping me from writing the formula to a cell.
Is there any solution for me to write the desired formula to a cell using VBA?