匹配" Casa" oSeries.name的字符串在VBA中不匹配

时间:2018-02-01 19:10:22

标签: string excel-vba comparison vba excel

这个VBA代码尝试绘制" Casa"黑色线:

Dim ActiveSheet As Worksheet
Dim oChart As Chart
Dim oSeries As Series

Set ActiveSheet = Sheets("Gráficas")
ActiveSheet.ChartObjects("Gráfico 200").Activate
Set oChart = ActiveChart

For numLine = 1 To oChart.SeriesCollection.Count
    Set oSeries = oChart.SeriesCollection(numLine)
    MsgBox oSeries.name
    If oSeries.name = "Casa" Then
        MsgBox "Success"
        oSeries.Format.Line.ForeColor.RGB = RGB(0, 0, 0)
    End If
Next

但是,我看到图表中所有行的名称,包括" Casa"但是没有绘制成功消息,也没有绘制黑色线条。 似乎字符串不匹配......但为什么?

0 个答案:

没有答案