在Excel中检查seriescollection公式

时间:2015-05-08 12:43:57

标签: excel vba excel-vba charts

我想检查seriescollection(1).formula是否是预期范围的预期字符串或.value,但我尝试的任何内容总是成功,无论数据如何:

If graf.SeriesCollection(1).Formula = _ 
       Range("Podatki!$B$1:$C$97;Podatki!$K$1:$L$97") Then
            MsgBox ("1")
End If

If graf.SeriesCollection(1).Values = _ 
       Range("Podatki!$B$1:$C$97;Podatki!$K$1:$L$97") Then
            MsgBox ("2")
End If

1 个答案:

答案 0 :(得分:1)

你错过了这行(第一行)中的Formula语句:

graf.SeriesCollection(1).Formula = Range("Podatki!$B$1:$C$97;Podatki!$K$1:$L$97") .Formula 

同样适用于values

graf.SeriesCollection(1).Value2 = Range("Podatki!$B$1:$C$97;Podatki!$K$1:$L$97").Value2