ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting Cells (https://www.excelbanter.com/excel-programming/272536-counting-cells.html)

Pedro Marques

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



Nick

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


.


Nick

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


.


Pedro Marques

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


.




Mike[_31_]

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


.


JMay

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


.






Myrna Larson[_2_]

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


.




All times are GMT +1. The time now is 05:27 PM.

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