PDA

View Full Version : Sumproduct Error



f2e4
06-02-2008, 06:44 AM
Hey people,

I have created the following function which works fine with typed in:


=SUMPRODUCT(Workload!J$4:J$1000, (Workload!$G$4:$G$1000 = $B4) + 0, (Workload!$F$4:$F$1000 = "Projects") + 0)

But when i try and enter this into VBA as the following:

Range("F4").Formula = "=SUMPRODUCT(Workload!J$4:J$1000, (Workload!$G$4:$G$1000 = $B4) + 0, (Workload!$F$4:$F$1000 = "Projects") + 0)"

I get a syntax error!!!

The theory is:

Sum a load of figures in column J providing the following are correct:

1. The correct name is valid in column G
2. 'Projects' is in column F

Anyone know why I am getting this error?

Bob Phillips
06-02-2008, 07:01 AM
Double-double-quotes

Range("F4").Formula = "=SUMPRODUCT(Workload!J$4:J$1000,(Workload!$G$4:$G$1000=$B4)+0,
(Workload!$F$4:$F$1000=""Projects"")+0)"

f2e4
06-02-2008, 07:11 AM
That fixed it

Thanks again xld