white_flag
Active Member
- Joined
- Mar 17, 2010
- Messages
- 331
Hello
I like to evaluate an excel function inside of VBA that will generate an graphic.
the excel function is like this:
but because is an R1C1 formula I receive error (type mismatch). can I rewrite formula 1 & formula 2 (just for the graphic part) ? to have the values from excel.
thank you
I like to evaluate an excel function inside of VBA that will generate an graphic.
the excel function is like this:
Code:
With rTopLeft.Offset(n, m)
formula1 = "INDEX(m_cla,MATCH(rc" & rTopLeft.Column & ",INDEX(m_cla,,1),1),IF(ISNA(MATCH(r" & rTopLeft.Row & "c,INDEX(m_cla,1,))),1,MIN(IF(ISNA(MATCH(r" & rTopLeft.Row & "c,INDEX(m_cla,1,),0)),MATCH(r" & rTopLeft.Row & "c,INDEX(m_cla,1,))+1,MATCH(r" & rTopLeft.Row & "c,INDEX(m_cla,1,),0)))))"
formula2 = "INDEX(pre,IF(ISNA(MATCH((2*r" & rTopLeft.Row & "c+rc" & rTopLeft.Column & "),INDEX(pre,,1))),1,MIN(IF(ISNA(MATCH((2*r" & rTopLeft.Row & "c+rc" & rTopLeft.Column & "),INDEX(pre,,1),0)),MATCH((2*r" & rTopLeft.Row & "c+rc" & rTopLeft.Column & "),INDEX(pre,,1))+1,MATCH((2*r" & rTopLeft.Row & "c+rc" & rTopLeft.Column & "),INDEX(pre,,1),0)))),2)"
.FormulaR1C1 = "=(" & formula1 & "+" & formula2 & ")"
..etc
'graphic
Dim f1 As Double, f2
f1 = f1 + Evaluate(formula1)
f2 = f2 + Evaluate(formula2)
Dim ChartObj As ChartObject
Dim ChartSeries As Series
Set ChartObj = ActiveSheet.ChartObjects.Add(Left:=100, Width:=550, Top:=75, Height:=325)
Set ChartSeries = ChartObj.Chart.SeriesCollection.NewSeries
With ChartSeries
.Type = xlPie
.Values = Array(f1, f2)
.XValues = Array("value 1", "value 2")
End With
thank you