CedricMattelaer
New Member
- Joined
- Jun 16, 2011
- Messages
- 37
Dear all,
I don't understand why a particular line of code doesn't work.
This is the code:
Perhaps this is easyier to read:
What I'm trying to do is to subtract the current value in the cell by a sumproduct of two matrices somewhere else on the same sheet.
Even if I try "=SUM(" instead of "=SUMPRODUCT", the execution of the code fails with error 1004: application- or object-defined error.
I tried other things too, as replacing the ranges by for example
but without success.
Anyh ideas on how to write this correctly?
I don't understand why a particular line of code doesn't work.
This is the code:
Code:
.Cells(624 + i, 2 + j) = .Cells(624 + i, 2 + j).Formula & "- SUMPRODUCT(" & .Range(.Cells(288 + game, 3 + 14 * j), .Cells(288 + game, 16 + 14 * j)).Address & ";" & .Range(.Cells(315, 3 + 14 * j), .Cells(315, 16 + 14 * j)).Address & ")"
Perhaps this is easyier to read:
Code:
Set GameRange = .Range(.Cells(288 + game, 3 + 14 * j), .Cells(288 + game, 16 + 14 * j))
Set OverflowRange = .Range(.Cells(315, 3 + 14 * j), .Cells(315, 16 + 14 * j))
.Cells(624 + i, 2 + team) = .Cells(624 + i, 2 + team).Formula & "- SUMPRODUCT(" & GameRange.Address & ";" & OverflowRange.Address & ")"
What I'm trying to do is to subtract the current value in the cell by a sumproduct of two matrices somewhere else on the same sheet.
Even if I try "=SUM(" instead of "=SUMPRODUCT", the execution of the code fails with error 1004: application- or object-defined error.
I tried other things too, as replacing the ranges by for example
Code:
.Cells(288 + game, 3 + 14 * j).Address & ":" & .Cells(288 + game, 16 + 14 * j).Address
Anyh ideas on how to write this correctly?