Excel実行画面
・ グラフの元データと集合ピラミッド縦棒グラフです。
・積み上げピラミッド縦棒、100% 積み上げピラミッド縦棒
・3-D ピラミッド縦棒、集合ピラミッド横棒
・積み上げピラミッド横棒、100% 積み上げピラミッド横棒
Excel VBA実行コード
Option Explicit
Private Sub CommandButton3_Click()
Dim trange As Range
Dim tCh As ChartObject
Dim ypos As Long
Dim stname As String
stname = ActiveSheet.Name
Set trange = Worksheets("Sheet1").Range("D1:F13")
ypos = 220
'作成領域
Set tCh = Worksheets("sheet1").ChartObjects.Add(20, ypos, 400, 200)
'集合ピラミッド縦棒
tCh.Chart.SetSourceData Source:=trange, PlotBy:=xlColumns
tCh.Chart.ChartType = xlPyramidColClustered
tCh.Chart.HasTitle = True
tCh.Chart.ChartTitle.Characters.Text = "売上推移 集合ピラミッド縦棒"
'作成領域
ypos = ypos + 220
Set tCh = Worksheets("sheet1").ChartObjects.Add(20, ypos, 400, 200)
'積み上げピラミッド縦棒
tCh.Chart.SetSourceData Source:=trange, PlotBy:=xlColumns
tCh.Chart.ChartType = xlPyramidColStacked
tCh.Chart.HasTitle = True
tCh.Chart.ChartTitle.Characters.Text = "売上推移 積み上げピラミッド縦棒"
'作成領域
ypos = ypos + 220
Set tCh = Worksheets("sheet1").ChartObjects.Add(20, ypos, 400, 200)
'100% 積み上げピラミッド縦棒
tCh.Chart.SetSourceData Source:=trange, PlotBy:=xlColumns
tCh.Chart.ChartType = xlPyramidColStacked100
tCh.Chart.HasTitle = True
tCh.Chart.ChartTitle.Characters.Text = "売上推移 100% 積み上げピラミッド縦棒"
'作成領域
ypos = ypos + 220
Set tCh = Worksheets("sheet1").ChartObjects.Add(20, ypos, 400, 200)
'3-D ピラミッド縦棒
tCh.Chart.SetSourceData Source:=trange, PlotBy:=xlColumns
tCh.Chart.ChartType = xlPyramidCol
tCh.Chart.HasTitle = True
tCh.Chart.ChartTitle.Characters.Text = "売上推移 3-D ピラミッド縦棒"
'作成領域
ypos = ypos + 220
Set tCh = Worksheets("sheet1").ChartObjects.Add(20, ypos, 400, 200)
'集合ピラミッド横棒
tCh.Chart.ChartType = xlPyramidBarClustered
tCh.Chart.SetSourceData Source:=trange, PlotBy:=xlColumns
tCh.Chart.HasTitle = True
tCh.Chart.ChartTitle.Characters.Text = "売上推移 集合ピラミッド横棒"
'作成領域
ypos = ypos + 220
Set tCh = Worksheets("sheet1").ChartObjects.Add(20, ypos, 400, 200)
'積み上げピラミッド横棒
tCh.Chart.ChartType = xlPyramidBarStacked
tCh.Chart.SetSourceData Source:=trange, PlotBy:=xlColumns
tCh.Chart.HasTitle = True
tCh.Chart.ChartTitle.Characters.Text = "売上推移 積み上げピラミッド横棒"
'作成領域
ypos = ypos + 220
Set tCh = Worksheets("sheet1").ChartObjects.Add(20, ypos, 400, 200)
'100% 積み上げピラミッド横棒
tCh.Chart.ChartType = xlPyramidBarStacked100
tCh.Chart.SetSourceData Source:=trange, PlotBy:=xlColumns
tCh.Chart.HasTitle = True
tCh.Chart.ChartTitle.Characters.Text = "売上推移 100% 積み上げピラミッド横棒"
End Sub