Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default What's the vba code equivalent for Countif

I tried using the foloowing code

Onlap = CountIf(Worksheets("A Grade").Range("I5:I104"), L)

and it says that countif is an undefined sub or function. What is the
correct VB code in 2003 to count the number of times a number occurs in a
range.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default What's the vba code equivalent for Countif

Use WorksheetFunction object:

Onlap = WorksheetFunction.CountIf(Worksheets("A Grade").Range("I5:I104"), L)

- Chirag

Shortcut Manager - Assign keyboard shortcuts to menu items and macros
http://officeone.mvps.org/xlsctmgr/xlsctmgr.html

"NDBC" wrote in message
...
I tried using the foloowing code

Onlap = CountIf(Worksheets("A Grade").Range("I5:I104"), L)

and it says that countif is an undefined sub or function. What is the
correct VB code in 2003 to count the number of times a number occurs in a
range.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default What's the vba code equivalent for Countif

Hi,

Simply tell the VB compiler it's a worksheetfunction

Onlap = WorksheetFunction.CountIf(Worksheets("A Grade").Range("I5:I104"), L)

Mike

"NDBC" wrote:

I tried using the foloowing code

Onlap = CountIf(Worksheets("A Grade").Range("I5:I104"), L)

and it says that countif is an undefined sub or function. What is the
correct VB code in 2003 to count the number of times a number occurs in a
range.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default What's the vba code equivalent for Countif

Not sure if it's exactly the same as your suggetions but it worked. I googled
whilst I was waiting for a response.

Onlap = Application.CountIf(Worksheets("A Grade").Range("I5:I104"), L)


"NDBC" wrote:

I tried using the foloowing code

Onlap = CountIf(Worksheets("A Grade").Range("I5:I104"), L)

and it says that countif is an undefined sub or function. What is the
correct VB code in 2003 to count the number of times a number occurs in a
range.

Thanks

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
how to do a countif - want cells that are before or on a certain dateand do not want to hard code that date SK08 Excel Worksheet Functions 1 December 2nd 08 05:26 PM
Mutiple COUNTIF or equivalent. [email protected] Excel Worksheet Functions 8 April 4th 08 02:31 PM
Creating the equivalent of a "hash code" for a workbook AMADHA Excel Discussion (Misc queries) 3 December 19th 07 09:04 AM
COUNTIF TO BUILD SIMPLE CODE Eddy Stan Excel Worksheet Functions 6 August 26th 07 11:06 PM
What is the Access equivalent of Excel's COUNTIF? RedStep Excel Discussion (Misc queries) 1 April 6th 05 09:36 PM


All times are GMT +1. The time now is 03:45 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"