Update formulas

T

ten

Hi,
I am trying to base my formula in my Excel based on some
Input I get from the user. This I save in iLastYear, and
have some labels (e.g. lBudgetLastYear etc) calculated
from this.

I tried using the formula under, but then Excel don't
recognize the variables I put in (e.g. iLastYear,
lBudgetLastYear etc)

ActiveCell.FormulaR1C1 = _
"=IF(RC[-8]=iLastYear,IF(RC[-7]
=1,lBudgetLastYear,lSum06LastYear),lSumSecondLastYear)"

How can I dynamically create an IF-sentence from VBA-code,
and put in one cell in Excel?

Thanks!
 
B

Bob Phillips

Ten,

Try this (untested I am afraid)


ActiveCell.FormulaR1C1 = _
"=IF(RC[-8]=" & iLastYear&"," _
"IF(RC[-7]=1," & lBudgetLastYear & "," & lSum06LastYear & ")," & _
lSumSecondLastYear & ")"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top