LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,388
Default Summing Boolean

Hi Dana,
OK, I concede. Count it is.
Dave.

"Dana DeLouis" wrote:

But WorksheetFunction.Sum(Range("A1:A10")) does not seem to work with
boolean entries, always returning 0.


Hi. Summing 'Boolean' entries doesn't make much sense compared to
"Counting."
However, to do so, I believe you need to first convert the boolean to a
value so that 'Sum can work.

Here's one way to Sum 'True as the value 1.

Sub Demo()
Dim x
x = WorksheetFunction.SumProduct([--MyRange])
End Sub

Just note that on a Worksheet, True is +1
I still think "Count" is what you want though :)

= = = = = = =
HTH :)
Dana DeLouis





On 2/22/2010 10:33 PM, Dave wrote:
Hi Dana,
But when we have boolean entries, Range("A1")+Range("A2")+Range("A3") works,
summing False's as 0's, and True's as -1's.
But WorksheetFunction.Sum(Range("A1:A10")) does not seem to work with
boolean entries, always returning 0.

Dave.

"Dana DeLouis" wrote:

But still puzzeled as to how we Sum a lot of cells in VBA

Hi. Here's one way...

Debug.Print WorksheetFunction.Sum(Range("A1:A10"))

HTH
Dana DeLouis



.



 
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
Boolean Math Art Excel Worksheet Functions 8 December 10th 09 09:35 PM
IF vs Boolean Brad Excel Discussion (Misc queries) 3 September 4th 09 01:58 AM
More on Boolean Epinn New Users to Excel 7 November 28th 06 09:29 AM
VBA Boolean Jeff Excel Discussion (Misc queries) 1 February 2nd 06 10:01 PM
Boolean masks Howard Excel Worksheet Functions 2 April 3rd 05 08:22 PM


All times are GMT +1. The time now is 11:15 AM.

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

About Us

"It's about Microsoft Excel"