You can do it with iterative calculation
=IF(ISNUMBER(G2),IF(G2=E2,TEXT(G2,"0"),G2+1),IF(VALUE(G2)=E2,G2,1))=IF(ISNUMBER(G2),IF(G2=1,A2:C4,MMULT(A2:C4,H2:J4)),H2:J4)
(this is an array formula, need to finish with CTRL+SHIFT+ENTER) Answer to this question describe with more details how the formula works.
*1 I suspect this applies to most of, if not all, the 64 bit office applications
This seems to be an issue with the 64 bit version of MS Office. In the 32 bit version the caret is used for the power operator, however in the 64 bit operator it is also used for variables of type LongLong (learn.microsoft.com/.../vba/.../longlong-data-type).^
In 64 bit VBA, when using *2 the IDE auto corrects Debug.Print to 2^2 but 2^; 2 is auto-corrected to 2 ^2; making the code compile-able. 2 ^ 2
By way of a solution, this is just one of those annoying things that users of 64bit VBA 'just need to know'.
Edit: Microsoft confirmed issue https://support.microsoft.com/en-gb/help/2454019/the-64-bit-office-2010-vba-compiler-shows-an-error-when-it-encounters
*2 I've also come to learn that the VBA behavior is different when using than assigning a variable (thanks to @ErikvonAsmuth)debug.Print