ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sumproduct error (https://www.excelbanter.com/excel-programming/283742-sumproduct-error.html)

Michael Singmin

Sumproduct error
 
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


Bill Manville

Sumproduct error
 
Michael Singmin wrote:
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


Gareth[_3_]

Sumproduct error
 
try ""w""

Gareth
"Michael Singmin" wrote in message
...
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 Singmin

Sumproduct error
 
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
=================================================
"Gareth" wrote:

try ""w""

Gareth
"Michael Singmin" wrote in message
.. .
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





All times are GMT +1. The time now is 03:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com