PDA

View Full Version : In need of a test vba to insert a value based on a date



viomman
02-06-2009, 12:35 PM
Ok this problem may be rather complicated to explain
At present i have a formula in each cell to test for a value then get the value.
=IF(LCCAParameters!D21=1,(LCCAParameters!E21)*(1+LCCAParameters!$G$5)^($F$5-LCCAParameters!$G$8))
Each one of these formulas relate the number cycle that the user in serts into the cell. ex. if the user puts a five in D21 the value in LCCAParameters!E21 will show up every five years for the cycle. The problem is that when I get past 49 years(1 year for each collumn. each collumn has the year as the title) the formula gets to be longer than 8 arguments and excel will not allow more than 8. here is an example of a lengthy formula for year 48.
=IF(LCCAParameters!D23=1,LCCAParameters!E23,IF(LCCAParameters!D23=48,LCCAPa rameters!E23,IF(LCCAParameters!D23=2,LCCAParameters!E23,IF(LCCAParameters!D 23=24,LCCAParameters!E23,IF(LCCAParameters!D23=3,LCCAParameters!E23,IF(LCCA Parameters!D23=16,LCCAParameters!E23,IF(LCCAParameters!D23=4,LCCAParameters !E23,IF(LCCAParameters!D23=12,LCCAParameters!E23,IF(LCCAParameters!D23=6,LC CAParameters!E23,IF(LCCAParameters!D23=8,LCCAParameters!E23,"0"))))))))))*(1+LCCAParameters!$G$5)^($BA$5-LCCAParameters!$G$8).
Each year(collumn) has a specific cycle it is realted to because of the year numbers multiplier. for instance year 5 will only cycle for a 5 and a 1, year 6 will only need 1,2,3,&6.
Does any one have a way to approach this in vba??
Please help desperate!

Bob Phillips
02-06-2009, 12:47 PM
=IF(ISNUMBER(MATCH(E1,{1,48,2,24,3,16,4,12,6,8},0)),LCCAParameters!E23,0)*( 1+LCCAParameters!$G$5)^($BA$5-LCCAParameters!$G$8)

viomman
02-06-2009, 12:59 PM
That worked. I still would be interested in vba doing the workload