Why does this COUNTIF code not work

C

ChipButtyMan

Hi,
I get an Expected; end of statement error with this code. The
word 'Missed' is highlighted as the point of the error.



Private Sub CommandButton8_Click()

Range ("L2").Formula = "=COUNTIF(E2:E25,"Missed code date")"

End Sub
 
R

Rick Rothstein

Quote marks that are internal to a string constant must be doubled up so
that VB knows where the string constant begins and ends. Try it this way...

Range("L2").Formula = "=COUNTIF(E2:E25,""Missed code date"")"
 
S

Susan

try double quotes around "Missed code date".......... it's reading it
as the end of the code.

E2:#25,""Missed code date"")"

hope that helps
:)
susan
 
J

JE McGimpsey

To include quotation marks within a string, you need to double them (or
replace them with CHR(34)):

Try:

Range ("L2").Formula = "=COUNTIF(E2:E25,""Missed code date"")"
 
M

Mike H

Hi,

You need to double-up on internal qiotes, try this

Range("L2").Formula = "=COUNTIF(E2:E25,""Missed code date"")"

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top