View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JP[_4_] JP[_4_] is offline
external usenet poster
 
Posts: 897
Default UDF or SUMPRODUCT with 51 named ranges?

SUMPRODUCT is better than the alternative worksheet solution (arrays).
A UDF would be marginally slower, because writing the result to Excel
from VBA is somewhat costly. But you could write VBA code to paste in
the formula 16 times, just changing the inputs :-)

--JP


On Sep 23, 5:13*pm, RyanH wrote:
I need a formula that will sum the numbers in Col.V, if Col.T <= J4 AND Col.U
= "X". *For example, if J4=10/1/08 the formula should = 5.50.

The data is in a sheet named "Global Schedule"
Col.T * * * * *Col.U * * * * *Col.V
9/1/08 * * * * *X * * * * * * *2.00
9/10/08 * * * *X * * * * * * *3.50
9/20/08 * * * * * * * * * * * *1.50
10/3/08 * * * * X * * * * * * 5.00

This formula works perfect in 2007, but I get an error in 2003. *I guess you
can't use entire columns in SUMPRODUCT in 2003.
=SUMPRODUCT(--('Global Schedule'!T:T<=$J$4),--('Global
Schedule'!U:U="X"),'Global Schedule'!V:V)

I used entire columns because I am constantly changing the number of rows in
'Global Schedule' worksheet. *So I basically need to have a dynamic range. *
So, Gary Keramidas suggested I name the ranges. Like this:
InsertNameDefine
Name: EngineeringDates
Refers to:
=OFFSET('Global Schedule'!T3,0,0,COUNTA('Global Schedule'!$A:$A),1)

Name: *EngineeringIndicators
Refers to:
=OFFSET('Global Schedule'!U3,0,1,COUNTA('Global Schedule'!$A:$A),1)

Name: *EngineeringHours
Refers to:
=OFFSET('Global Schedule'!V3,0,0,COUNTA('Global Schedule'!$A:$A),1)

Then use Formula:
=SUMPRODUCT(--(EngineeringDates<=J4),--(EngineeringIndicators="X",
EngineeringHours)

This formula works great, but I was concerned because I have to do this 16
more times, for each department we have at our company. *Will this cause a
memory problem and cause the application to run slow? *I assume all these
Names are stored in Memory (RAM), right?

Would it be more efficient, compute faster, and use less memory if I had a
UDF?
--
Cheers,
Ryan