简体   繁体   中英

Chart returns different results depending on size of range

I try to make program in macro-excel that show chart of dec 2012- curent month data.

I want X-axis is the month, but only in january, the axis n the legend switched.

My code:

Public Sub pi()

    Dim bulan1
    Dim bulan2
    Dim kpi As Worksheet
    Dim data As Worksheet
    Dim a As Integer
    Dim x As Integer
    Dim xaxis As Axis


    Set kpi = ThisWorkbook.Sheets("KPI chart")
    Set data = ThisWorkbook.Sheets("data")

    bulan1 = Month(Now)

    For a = 2 To 14
        bulan2 = Month(Cells(54, a).Value)

        If bulan2 = bulan1 Then 

        End If
    Next

    kpi.ChartObjects("Chart 16").Activate
    ActiveChart.SetSourceData Source:=Range(data.Cells(54, 1), data.Cells(57, a))

End Sub

Picture : http://melegenda.tumblr.com/image/72825632452

I think I missed something? (I use excel 2007)

I don't know what is this, but it works. ahhaha just add ActiveChart.PlotBy = xlRows before end sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM