Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am attempting to move an Excel formula from a worksheet and place it
in an Excel VBA function. Naively, I thought that I could simply take the worksheet equation, pass it variables, and add "Application." to all worksheet function. I took the "Application." out of the VBA function to make it easier to read. Unfortunately this does not work for the OFFSET function, but I have not been able to figure out just why. Excel Worksheet Function: =SUMPRODUCT(OFFSET(CI9,-MIN(CF9-Year_First,Fac_Depr),0,MIN(CF9-Year_First+1,Fac_Depr+1),1), OFFSET(FirstInvFacTangDrillDepr,-MIN(CF9-Year_First,Fac_Depr),0,MIN(CF9-Year_First+1,Fac_Depr+1),1)) CF9,CI9 and named cells are single cells as opposed to multiple ones such as in a range Attempted Excel VBA Function: Function FirstYearDepreciation(Current_Year, Year_First, Fac_Depr, FirstInvFacTangDrillDepr, Eligible_Depr) Dim Current_Year As Double Dim Year_First As Double Dim Fac_Depr As Integer Dim FirstInvFacTangDrillDepr As Double Dim Eligible_Depr As Variant FirstYearDepreciation = SumProduct( _ Offset(Eligible_Depr, -Min(Current_Year - Year_First, Fac_Depr), 0, Min(Current_Year - Year_First + 1, Fac_Depr + 1), 1), _ Offset(FirstInvFacTangDrillDepr, -Min(Current_Year - Year_First, Fac_Depr), 0, Min(Current_Year - Year_First + 1, Fac_Depr + 1), 1)) End Function Can anyone shed some light on this? Thanks in advance. Floyd |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
large function result as reference for offset function | Excel Discussion (Misc queries) | |||
XL2002 - OFFSET function and LARGE function | Excel Worksheet Functions | |||
Offset function in Excel 2003 | Excel Worksheet Functions | |||
Offset function with nested match function not finding host ss. | Excel Worksheet Functions | |||
help with offset function | Excel Worksheet Functions |