2016-05-10 5 views
0

棒グラフを作成しようとしていますが、水平方向にしています。これまでのところ、私は次のコードでそれを垂直にすることしかできません。私は を掘り下げており、人の情報源は垂直方向のみを示しています。Excel VBAでグラフの向きを変更する

Sub test_tic_count_graph() 

    Dim chtTicCount As chart 
    Dim ticCountGraph As Worksheet 

    Set ticCountGraph = ActiveWorkbook.Sheets("ticCountGraph") 
    Set chtTicCount = ticCountGraph.Shapes.AddChart(xlColumnClustered).chart 

    With chtTicCount 

        .SetSourceData Source:=ticCountGraph.Range("A1:B9") 


        ''Activating the xlValue so we can refer to x-y values. 
        .HasAxis(xlValue, xlPrimary) = True 
        .HasAxis(xlValue, xlSecondary) = True 

        .Legend.Font.Size = 10 
        '' Sets legend position 100 points from top. 
        .Legend.Top = 100 


        ''Label the X - axis. Note it's xlCategory. 
        With .Axes(xlValue, xlPrimary) 
         .HasTitle = True 
         .AxisTitle.Text = "DEVICE" 
         .AxisTitle.Font.Size = 10 

         '' Modify tickmark labels font size. 
         .TickLabels.Font.Size = 10 

        End With 

        '' Label the Y - axis. Note it's xlValue. 
        With .Axes(xlCategory, xlPrimary) 
         .HasTitle = True 
         ''.AxisTitle.Text = "CPU %" 
         .AxisTitle.Font.Size = 10 
         .TickLabels.Font.Size = 10 
         ''.MaximumScale = 1 

        End With 

      End With 

    End Sub 

答えて

0

xlColumnClusteredへ 方法は、垂直バーのChartTypeプロパティの値がされています。水平バーには、おそらくxlBarClusteredが必要です。

関連する問題