Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Counting Cells

Hi
What code should I write in order to count only the positive value of a
pre-defined range: Range(Cells(42, 2), Cells(77, 2))

Thanks
Pedro


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Counting Cells

Total = 0

For J = 42 to 77

If Cells(J, 2).Value 0 Then

Total = Total + Cells(J, 2).Value

Next J



-----Original Message-----
Hi
What code should I write in order to count only the

positive value of a
pre-defined range: Range(Cells(42, 2), Cells(77, 2))

Thanks
Pedro


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Counting Cells

Thinking about it if you only want to count the number of
cells rather than sum them you should use

application.worksheetfunction.countif


-----Original Message-----
Hi
What code should I write in order to count only the

positive value of a
pre-defined range: Range(Cells(42, 2), Cells(77, 2))

Thanks
Pedro


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Counting Cells

Thanks Nick

I tried to use the application.worksheetfunction.countif

Using strRet = Application.WorksheetFunction.CountIf((Range(Cells (42, 2),
Cells(77, 2))), Cells.Value 0)

But it gives me an error.

Do you know what do I have to change?

"Nick" wrote in message
...
Thinking about it if you only want to count the number of
cells rather than sum them you should use

application.worksheetfunction.countif


-----Original Message-----
Hi
What code should I write in order to count only the

positive value of a
pre-defined range: Range(Cells(42, 2), Cells(77, 2))

Thanks
Pedro


.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Counting Cells

One command, no looping required.

Application.WorksheetFunction.CountIf(Range(Cells( 42, 2),
Cells(77, 2)),"0")


-----Original Message-----
Hi
What code should I write in order to count only the

positive value of a
pre-defined range: Range(Cells(42, 2), Cells(77, 2))

Thanks
Pedro


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Counting Cells

FWIW:

The worksheet function is:

=COUNTIF(B42:B77,""&0)

HTH

"Pedro Marques" wrote in message
...
Thanks Nick

I tried to use the application.worksheetfunction.countif

Using strRet = Application.WorksheetFunction.CountIf((Range(Cells (42, 2),
Cells(77, 2))), Cells.Value 0)

But it gives me an error.

Do you know what do I have to change?

"Nick" wrote in message
...
Thinking about it if you only want to count the number of
cells rather than sum them you should use

application.worksheetfunction.countif


-----Original Message-----
Hi
What code should I write in order to count only the

positive value of a
pre-defined range: Range(Cells(42, 2), Cells(77, 2))

Thanks
Pedro


.





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Counting Cells

And if he *does* want to sum them, he can use SUMIF <g.


On Thu, 24 Jul 2003 03:38:53 -0700, "Nick" wrote:

Thinking about it if you only want to count the number of
cells rather than sum them you should use

application.worksheetfunction.countif


-----Original Message-----
Hi
What code should I write in order to count only the

positive value of a
pre-defined range: Range(Cells(42, 2), Cells(77, 2))

Thanks
Pedro


.


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
Counting the number of cells between 2 seperate cells mpenkala Excel Discussion (Misc queries) 2 April 16th 08 05:04 PM
counting cells that are 0 in a range of non-contiguous cells Mark Excel Worksheet Functions 9 March 14th 07 02:45 PM
Query counting cells in a row that exactly match cells in another Marlsnz Excel Discussion (Misc queries) 1 June 2nd 06 07:08 AM
Complicated counting of cells (based on other cells contents) George Excel Worksheet Functions 3 November 7th 05 06:39 PM
Counting empty cells within a range of cells Rosehill - ExcelForums.com New Users to Excel 0 April 7th 05 12:47 AM


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