View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default profit/loss calculator

You have to build tthe functions as strings Ranges can either be strings or
ranges. You can also build the formulas as A1 addressing or R1C1 address.

1) Exmple 1
Range("A1").formula = "=sum(B5:C10)"

2) Example 2
Range("A1").formulaR1C1 = "=sum(R5C2:R10C3)"

3) Example 3
set myRange = Range("B5:C10")
Range("A1").formula = "=sum(" & myRange & ")"



"franky" wrote:

Hi again Joel

Thanks alot! I am on the right track. I can get it to insert the
values and use the values from my userform in the above posted
formulas. But how do i get values from my sheet into my formulas?? Say
I want to use the value in the sell offset from the ISIN code in the
"amount" column in the following formula

Average price/amount + current price/amount

I´ve tried by defing:

c.Offset(rowoffset:=0, columnoffset:=2) = Amount

And then using this value in the formula.

But this simply overwrites the cell value with zero instead of taking
the value and using it in the formula.