Re: SUM(IF..... in Visual basic
From: JE McGimpsey (jemcgimpsey_at_mvps.org)
Date: 02/18/04
- Next message: Dave Peterson: "Re: excel multiple files saved in 1 file"
- Previous message: Bill Plenge: "Re: Lookup value above cells with non-zero value"
- In reply to: Tom: "Re: SUM(IF..... in Visual basic"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Feb 2004 16:21:13 -0700
Did you try it?
Your function:
Multiplies two boolean arrays (implicitly coercing the boolean
values to numeric with the * operator). IF() causes elements of the
third array to be placed in a fourth array if the result of the
multiplication was not zero for each element. If the result of the
multiplication was 0, then FALSE is inserted into the fourth array.
Finally, that array is SUMmed.
My function:
Two boolean arrays are explicitly coerced to numeric via the double
unary minus operators. The first, second and third array are then
multiplied together, yeilding the value in the third array for elements
in which both elements in the first two arrays are TRUE/1, and 0 if
either of the elements in the first two arrays are FALSE/0. The
resulting array is summed.
Much the same thing, but SUMPRODUCT is faster.
In article <4033e09f$0$21301$cc9e4d1f@news.dial.pipex.com>,
"Tom" <reply@list.com> wrote:
> Regarding SUMPRODUCT, either I understand it wrong, but what you are
> suggesting is a different function to what I have got by sum(if( doing,
>
> I can not see how SUMPRODUCT will ever do what I need in this case
>
> thanks
>
> tom
> "JE McGimpsey" <jemcgimpsey@mvps.org> wrote in message
> news:jemcgimpsey-68FADD.09055718022004@msnews.microsoft.com...
> > It's certainly possible, but would have a horrendous disadvantage in
> > both speed and memory. In general, using VBA is much slower than using
> > XL's built-in compiled and optimized functions.
> >
> > There is a speed advantage to using SUMPRODUCT() rather than SUM(IF()),
> > though (Note: SUMPRODUCT is not array-entered):
> >
> > =SUMPRODUCT(--(DataStore!$I$4:$I$39=$E$24),
> > --(DataStore!$E$4:$E$39=$F$9), DataStore!J$4:J$39)
> >
> >
> >
> > In article <40328723$0$21298$cc9e4d1f@news.dial.pipex.com>,
> > "Tom" <reply@list.com> wrote:
> >
> > > I have a simple sumif that does two conditional test:
> > >
> > >
> > >
> > >
> =SUM(IF(('DataStore'!$I$4:$I$39=$E24)*('DataStore'!$E$4:$E$39=$F$9),'DataSto
> > > re'!J$4:J$39))
- Next message: Dave Peterson: "Re: excel multiple files saved in 1 file"
- Previous message: Bill Plenge: "Re: Lookup value above cells with non-zero value"
- In reply to: Tom: "Re: SUM(IF..... in Visual basic"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|