Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Boolean Math | Excel Worksheet Functions | |||
IF vs Boolean | Excel Discussion (Misc queries) | |||
More on Boolean | New Users to Excel | |||
VBA Boolean | Excel Discussion (Misc queries) | |||
Boolean masks | Excel Worksheet Functions |