Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default UDF or SUMPRODUCT with 51 named ranges?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,389
Default UDF or SUMPRODUCT with 51 named ranges?

Just change the range to encompass the entire column, as in:
=SUMPRODUCT(--('Global Schedule'!T1:T65536<=$J$4),--('Global
Schedule'!U1:U65536="X"),'Global Schedule'!V1:V65536)

Then it will work in both 2003 and 2007.

Regards,
Fred.

"RyanH" wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default UDF or SUMPRODUCT with 51 named ranges?

Fred, I wish it was that simple. Problem is when I delete rows the the max
row number gets smaller, eventually sabotaging the formula. For example,
T3:T65000 will change to T3:64775 if i delete 25 rows.

JP, how could I write the UDF in VBA. Here is a rough idea of what I would
be looking for: I know this doesn't work.


Public Function ScheduledHrs(DateColumn As String, Criteria1 As String, _
IndicatorColumn As String, Criteria2 As
String, _
HoursColumn As String)

'DateColumn = Would be the Col. Letter the Dates are located in
'Criteria1 = "<=$J$4"
'IndicatorColumn = Would be the Col. Letter that contains "X" 's
'Criteria2 = "=X"
'HoursColumn = Would be the Col. Letter where the dept. hours are located.

Dim wksGlobal As Worksheet
Dim lngLastRow As Long
Dim rngDates As Range
Dim rngIndicators As Range
Dim rngHours As Range

Set wksGlobal = Sheets("Global Schedule")
lngLastRow = wksGlobal.Cells(Rows.Count, "A").End(xlUp).Row

Set rngDates = wksGlobal.Range(Cells(3, DateColumn), Cells(lngLastRow,
DateColumn))
Set rngIndicators = wksGlobal.Range(Cells(3, IndicatorColumn),
Cells(lngLastRow, IndicatorColumn))
Set rngHours = wksGlobal.Range(Cells(3, HoursColumn), Cells(lngLastRow,
HoursColumn))

ScheduledHrs = WorksheetFunction.SumProduct(--(rngDates & Criteria1), _
--(rngIndicators &
Criteria2), _
rngHours)

End Function
--
Cheers,
Ryan


"Fred Smith" wrote:

Just change the range to encompass the entire column, as in:
=SUMPRODUCT(--('Global Schedule'!T1:T65536<=$J$4),--('Global
Schedule'!U1:U65536="X"),'Global Schedule'!V1:V65536)

Then it will work in both 2003 and 2007.

Regards,
Fred.

"RyanH" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default UDF or SUMPRODUCT with 51 named ranges?

Looks alright to me, but I'll take a look at it again in the morning.

--JP

On Sep 23, 9:12*pm, RyanH wrote:
JP, how could I write the UDF in VBA. *Here is a rough idea of what I would
be looking for: *I know this doesn't work.

Public Function ScheduledHrs(DateColumn As String, Criteria1 As String, _
* * * * * * * * * * * * * * * * IndicatorColumn As String, Criteria2 As
String, _
* * * * * * * * * * * * * * * * HoursColumn As String)



  #6   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default UDF or SUMPRODUCT with 51 named ranges?

If you write it like this, your range reference won't change as you
insert/delete rows.
=SUM(A1:INDEX(A:A,65535))


"RyanH" wrote:

Fred, I wish it was that simple. Problem is when I delete rows the the max
row number gets smaller, eventually sabotaging the formula. For example,
T3:T65000 will change to T3:64775 if i delete 25 rows.

JP, how could I write the UDF in VBA. Here is a rough idea of what I would
be looking for: I know this doesn't work.


Public Function ScheduledHrs(DateColumn As String, Criteria1 As String, _
IndicatorColumn As String, Criteria2 As
String, _
HoursColumn As String)

'DateColumn = Would be the Col. Letter the Dates are located in
'Criteria1 = "<=$J$4"
'IndicatorColumn = Would be the Col. Letter that contains "X" 's
'Criteria2 = "=X"
'HoursColumn = Would be the Col. Letter where the dept. hours are located.

Dim wksGlobal As Worksheet
Dim lngLastRow As Long
Dim rngDates As Range
Dim rngIndicators As Range
Dim rngHours As Range

Set wksGlobal = Sheets("Global Schedule")
lngLastRow = wksGlobal.Cells(Rows.Count, "A").End(xlUp).Row

Set rngDates = wksGlobal.Range(Cells(3, DateColumn), Cells(lngLastRow,
DateColumn))
Set rngIndicators = wksGlobal.Range(Cells(3, IndicatorColumn),
Cells(lngLastRow, IndicatorColumn))
Set rngHours = wksGlobal.Range(Cells(3, HoursColumn), Cells(lngLastRow,
HoursColumn))

ScheduledHrs = WorksheetFunction.SumProduct(--(rngDates & Criteria1), _
--(rngIndicators &
Criteria2), _
rngHours)

End Function
--
Cheers,
Ryan


"Fred Smith" wrote:

Just change the range to encompass the entire column, as in:
=SUMPRODUCT(--('Global Schedule'!T1:T65536<=$J$4),--('Global
Schedule'!U1:U65536="X"),'Global Schedule'!V1:V65536)

Then it will work in both 2003 and 2007.

Regards,
Fred.

"RyanH" wrote in message
...
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



Reply
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
using Sumproduct with named ranges Jenny S Excel Discussion (Misc queries) 1 April 21st 10 12:16 PM
Named ranges scope / workbook/worksheet level named ranges- changeswith variable use... christian_spaceman Excel Programming 3 December 24th 07 01:15 PM
Using a series of named ranges in SUMPRODUCT JzP Excel Worksheet Functions 7 June 18th 07 05:29 PM
help on sumproduct of named ranges driller Excel Worksheet Functions 1 May 27th 07 12:45 AM
Sumproduct using named ranges and multiple criteria A.Gates Excel Discussion (Misc queries) 5 January 26th 07 11:41 PM


All times are GMT +1. The time now is 10:07 PM.

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

About Us

"It's about Microsoft Excel"