Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function Updates from another sheet
I have the following function on Sheet1. I then go to Sheet2 and
change the one variable, which is the CounterMarker range value. On Sheet2, I have a linked cell to the result of the calculation. It reports #VALUE! When CounterMarker's value is changed. I then go back to the sheet with the function and hit F9 it calculates just fine. When I step through the code I see that the CounterMarker range is empty when changed Sheet2, thus giving me the error message. My question is how can I fix the function such that it can calculate when I make changes to CounterMarker's value on Sheet2? Variables: 'Current_Year = 2005 (fixed value) 'Year_First = 2005 (fixed value) 'DepreciationSchedule = 7 (fixed value) 'AmortizationFactors = 0.1429 (fixed value) 'EOFL - 2017 (fixed value) 'CounterMarker = range (value changes) Function YearlyDepreciation(Current_Year As Double, Year_First As Double, DepreciationSchedule As Integer _ , AmortizationFactors As Variant, EligibleDepreciation As Variant, EOFL As Double, CounterMarker As Range) As Variant Application.Volatile True Application.Calculate Dim Rng1 As Range Dim Rng2 As Range Dim Rng1Addr As String Dim Rng2Addr As String Dim YearDelta As Double Dim LeftTextSegment1 As String Dim RightTextSegment1 As String Dim LeftTextSegment2 As String Dim RightTextSegment2 As String Set Rng1 = EligibleDepreciation Set Rng2 = AmortizationFactors YearDelta = Current_Year - Year_First Rng1Addr = EligibleDepreciation.Offset(-WorksheetFunction.Min(YearDelta, DepreciationSchedule), 0) _ .Resize(WorksheetFunction.Min(YearDelta + 1, DepreciationSchedule + 1), 1).Address Rng2Addr = Rng2.Offset(-WorksheetFunction.Min(YearDelta, DepreciationSchedule), 0) _ .Resize(WorksheetFunction.Min(YearDelta + 1, DepreciationSchedule + 1), 1).Address YearlyDepreciation = Application.WorksheetFunction.SumProduct(Range(Rng 1Addr), Range(Rng2Addr)) End Function Thanks in advance. Floyd |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Multiple sheet updates | Excel Worksheet Functions | |||
enter figures in timesheets and it updates a job costing sheet | New Users to Excel | |||
How do I create a sheet in Excel that updates itself from other sh | Excel Worksheet Functions | |||
Expiry Date for further updates into Sheet | Excel Programming | |||
Expiry Date for further updates into Sheet | Excel Programming |