Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default OFFSET and SUMPRODUCT

All:

Here is a complex function using OFFSET and SUMPRODUCT. I belive the
OFFSET commands are finally working, leaving the SUMPRODUCT.

I have compiled this function without error. However, when executing
the function I get #VALUE!.

Is there something wrong with the syntax for SUMPRODUCT?


Function FirstYearDepreciation(Current_Year As Double, Year_First As
Double, Fac_Depr As Integer)
Dim FirstRange As Range
Dim SecondRange As Range
Dim YearDelta As Double
Set FirstRange = Range("CI9")
Set SecondRange = Range("DO40")
YearDelta = Current_Year - Year_First


FirstYearDepreciation = Application.WorksheetFunction.SumProduct( _
FirstRange.Offset(-WorksheetFunction.Min(YearDelta, Fac_Depr), 0) _
.Resize(WorksheetFunction.Min(YearDelta + 1, Fac_Depr + 1),
1).Address, _
SecondRange.Offset(-WorksheetFunction.Min(YearDelta, Fac_Depr), 0)
_
.Resize(WorksheetFunction.Min(YearDelta + 1, Fac_Depr + 1),
1).Address)
End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default OFFSET and SUMPRODUCT

This might be easier to understand:

Function FirstYearDepreciation(Current_Year As Double, Year_First As
Double, Fac_Depr As Integer)
Dim FirstRange As Range
Dim SecondRange As Range
Dim YearDelta As Double
Set FirstRange = Range("CI9")
Set SecondRange = Range("DO40")
Dim SRng1Addr As String
Dim SRng2Addr As String
YearDelta = Current_Year - Year_First

SRng1Addr = FirstRange.Offset(-WorksheetFunction.Min(YearDelta,
Fac_Depr), 0).Resize(WorksheetFunction.Min(YearDelta + 1, Fac_Depr +
1), 1).Address(external:=True)
SRng2Addr = SecondRange.Offset(-WorksheetFunction.Min(YearDelta,
Fac_Depr), 0).Resize(WorksheetFunction.Min(YearDelta + 1, Fac_Depr +
1), 1).Address(external:=True)

FirstYearDepreciation = WorksheetFunction.SumProduct(SRng1Addr,
SRng2Addr)
End Function

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 offset in sumproduct, is it possible? mike in texas Excel Worksheet Functions 2 November 21st 08 04:36 PM
Sumproduct Offset with an If Steve[_4_] Excel Worksheet Functions 2 March 28th 08 08:43 PM
Sumproduct and offset Maarten Excel Worksheet Functions 4 October 28th 05 10:23 AM
Sumproduct with offset? MJ Excel Worksheet Functions 3 March 15th 05 03:34 PM
SUMPRODUCT using offset from ROW if X marks the spot The Shaffer s Excel Worksheet Functions 3 November 2nd 04 06:14 AM


All times are GMT +1. The time now is 08:56 PM.

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"