Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Why does this COUNTIF code not work

Thanks very much everyone.
Much appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIF doesn't work KenH Excel Discussion (Misc queries) 12 October 13th 09 03:52 PM
Will countif work? Neall Excel Programming 6 October 25th 07 06:02 PM
How to get Countif to work this out? Wind54Surfer Excel Worksheet Functions 3 September 16th 07 03:06 AM
Countif does not work c4ec Excel Worksheet Functions 2 February 23rd 07 03:56 PM
CountIf should work across sheets [email protected] Excel Worksheet Functions 2 October 21st 06 11:39 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"