CountIf cell value greater than 14

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I have the code below and it is not working ?

I get a compile error: Sub or function not defined and COUNTIF is highlited ?

Any help woud be appreciated

Sub testToC()
'
Dim poDelay As Variant, lstCell As Long

lstCell = Cells(Rows.Count, "A").End(xlUp).Row
poDelay = CountIf("Q3:Q" & lstCell, ">14")

End Sub
 
Hi Les,

Use

Application.Countif(Range"Q3

etc
| Hello all,
|
| I have the code below and it is not working ?
|
| I get a compile error: Sub or function not defined and COUNTIF is highlited ?
|
| Any help woud be appreciated
|
| Sub testToC()
| '
| Dim poDelay As Variant, lstCell As Long
|
| lstCell = Cells(Rows.Count, "A").End(xlUp).Row
| poDelay = CountIf("Q3:Q" & lstCell, ">14")
|
| End Sub
|
| --
| Les
 
Since CountIf is a worksheet function, you have to preceed it with

Application.Worksheetfunction.CountIf(etcetera


greetings
 
Hi Niek,

Thank you for your reply, that works but the variable gives me an error:2015 ?
 
This seems to work, although I don't have your data

Sub testToC()
'
Dim poDelay As Variant, lstCell As Long

lstCell = Cells(Rows.Count, "A").End(xlUp).Row
poDelay = Application.CountIf(Range("Q3:Q" & lstCell), ">14")

End Sub


--
Kind regards,

Niek Otten
Microsoft MVP - Excel

| Hi Niek,
|
| Thank you for your reply, that works but the variable gives me an error:2015 ?
|
| --
| Les
|
|
| "Niek Otten" wrote:
|
| > Hi Les,
| >
| > Use
| >
| > Application.Countif(Range"Q3
| >
| > etc
| > | Hello all,
| > |
| > | I have the code below and it is not working ?
| > |
| > | I get a compile error: Sub or function not defined and COUNTIF is highlited ?
| > |
| > | Any help woud be appreciated
| > |
| > | Sub testToC()
| > | '
| > | Dim poDelay As Variant, lstCell As Long
| > |
| > | lstCell = Cells(Rows.Count, "A").End(xlUp).Row
| > | poDelay = CountIf("Q3:Q" & lstCell, ">14")
| > |
| > | End Sub
| > |
| > | --
| > | Les
| >
| >
| >
 

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

Back
Top