ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why does this COUNTIF code not work (https://www.excelbanter.com/excel-programming/418774-why-does-countif-code-not-work.html)

ChipButtyMan

Why does this COUNTIF code not work
 
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

Rick Rothstein

Why does this COUNTIF code not work
 
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"")"

--
Rick (MVP - Excel)


"ChipButtyMan" wrote in message
...
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



Susan

Why does this COUNTIF code not work
 
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


On Oct 20, 2:22*pm, ChipButtyMan wrote:
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



JE McGimpsey

Why does this COUNTIF code not work
 
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"")"


In article
,
ChipButtyMan wrote:

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


Mike H

Why does this COUNTIF code not work
 
Hi,

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

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

Mike

"ChipButtyMan" wrote:

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


ChipButtyMan

Why does this COUNTIF code not work
 
Thanks very much everyone.
Much appreciated.



All times are GMT +1. The time now is 11:21 PM.

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