3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VBAでExcelのグラフ(レーダーチャート)を作成する

Last updated at Posted at 2014-09-09

VBAでグラフを作成するのに必要なものは、

  1. ヘッダ
  2. データセット
    の2つ。
    新規作成したchartオブジェクトに、上記2つを渡せばグラフを作成できる。

各データセットの装飾(色や塗り)は、chartオブジェクトから取得したSeriesオブジェクトを操作することで可能。

グラフを作成


'ヘッダを Range オブジェクトとして設定
Set headerRange = sheet.Range(cell-1, cell-2)

'データセットを Range オブジェクトとして設定
Set dataRange = sheet.Range(cell-3, cell-4)

'chartオブジェクトに渡すため、ヘッダRangeとデータセットRangeを結合する
Set gRange = Union(headerRange, dataRange)

'chartオブジェクトを作成する
Set  rChart = sheet.ChartObjects.Add( x, y, width, height )
rChart.Chart.setSourceData gRange
rChart.Chart.ChartType = xlRaderFilled  'レーダーチャート以外のタイプにする場合はここを変更

グラフの設定を変更

'グラフの種類を変更する
rChart.Chart.ChartType = xxxx

'凡例を表示するかどうか
rChart.Chart.hasLegend = True / False

'値の目盛りラベルを表示しない
rChart.Chart.Axes(xlValue).TickLabelPosition = xlNone

レーダーチャートグラフで、データセットの設定を変更

'※ 指定したいデータセットは
'rChart.Chart.SeriesCollection(x)で取得できる

'塗りつぶしの色を変更する
rChart.Chart.SeriesCollection(x).Format.Fill.ForeColor.RGB = RGB( r, g, b )

'塗りつぶしを無し(透明)にする
rChart.Chart.SeriesCollection(x).Format.Fill.Visiblae = msoFalse


'線の細さを変更する
rChart.Chart.SeriesCollection(x).Border.Weight = XXXX

'線の色を変更する
rChart.Chart.SeriesCollection(x).Format.Line.ForeColor.RGB = RGB( r, g, b )

'線にマーカーを表示する
rChart.Chart.SeriesCollection(x).ChartType = xlRaderMarkers


'順番を変更する(凡例の順番も準じる)。xxxxの値が小さいほど上になる。
rChart.Chart.SeriesCollection(x).PlotOrder = xxxx

3
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?