Sumproduct error

  • Thread starter Thread starter Michael Singmin
  • Start date Start date
M

Michael Singmin

Hello group,

I want to place in a cell C8 with VBA the statement
=Sumproduct((G3:G2500="w")*1)

Range("C8") = "=Sumproduct((G3:G2500="w")*1)"
Compile error, Expected: end of statement

Obviously, the inverted commas around w are causing the problem.
Is there a solution for this ?

I have a workaround of putting "w" in F1 and referencing F1 instead of
"w"

Thanks,

Michael Singmin
 
Michael said:
Range("C8") = "=Sumproduct((G3:G2500="w")*1)"
Compile error, Expected: end of statement

Obviously, the inverted commas around w are causing the problem.
Is there a solution for this ?

Range("C8") = "=Sumproduct((G3:G2500=""w"")*1)"

ie to include a " in a quoted string, insert ""

Is there a good reason not to use
"=COUNTIF(G3:G2500,""w"")"
?

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
 
Thanks Gareth and Bill,

I could have sworn I tried the "" and it gave an error.

Bill, I am using Sumproduct because I am looking up 3 criteria
of which the ""w"" is one.

Thanks,

Michael
=================================================
 
Back
Top