| 本章では、グラフ操作についてコードサンプルを示しながら説明しています。 | |||||||||
|
|||||||||
| 【グラフシート】 ブックにグラフを作成する オブジェクトの取得 Worksheets("シート名").ChartObjects("グラフ名") 【埋め込みグラフ】 ワークシート上にグラフを作成する オブジェクトの取得 Workbooks("ブック名").ChartObjects("グラフ名") |
|||||||||
|
|||||||||
|
|
【埋め込みグラフの作成】 Worksheets("シート名").ChartObjects.Add(Left,Top,Width,Height) :数字は左端、上端からの位置 ex With ActiveSheet.ChartObjects.Add(50,40,300,150) Chart.ChartType = xColumnClustered : グラフの種類(集合縦棒) Chart.SetSourceData Source:=Activesheet.Range("A3:C9),PlotBy:=xlRows :データ系列は行基準 End With 【グラフシートへのグラフ作成】 Workbookets("ブック名").Charts.Add(Before,After,Count) Before:指定したワークシートの前にグラフシートを追加(省略可能) After:指定したワークシートの後にグラフシートを追加(省略可能) Count:追加するグラフシートの数(省略可能) ex ActiveWorkbook.Charts.Add With ActiveChart ChartType = xColumnClustered : グラフの種類(集合縦棒) SetSourceData Source:=Worksheet(1).Range("A3:C9),PlotBy:=xlRows End With |
||||||||
|
|||||||||
| With ActiveChart .HASTitle = True . With ChartTitle Text = "チャートタイトル" . Orientation = xlHorizontal . Font.Size = 12 Font.Bold = True Border.LineStyle = xlContinuous End With End With |
|||||||||
|
|
|||||||||
|
|||||||||
|
With ActiveSheet.ChartObjects(1)
.Chart.ChartArea.AutoScaleFont = False .Left = 10 Top = 10 .Width = 300 .Hight = 300 End With |
|||||||||
|
|||||||||
|
With ActiveChart.Axes(xlValue) 数値軸に対して指定
..HasTitle = True ..AxisTitle.Text = "ラベルの文字" .AxisTitle.Font.Size = 12 ..AxisTitle.Orientation = xlHorizontal ..AxisTitle.Left = 30 .AxisTitle.Top = 20 End With |
|||||||||
|
|||||||||
|
With ActiveChart
..HasLegend = True ..Legend.Position = xlLegendPositionBottom .Legend.Font.Itaric = True End With |
|||||||||
|
|||||||||
|
CMax = ActiveChart.SeriesCollection.Count
For Cnt = 1 To CMax With ActiveChart.SeriesCollection(Cnt) .HasDataLabels = True With DataLabels .Font.Bold = True Font.Italic = True Font.Size = 12 .Position = xlLabelPositionOutSideEnd End With End With |
|||||||||
|
|||||||||
|
Sheet1 の図形オブジェクト 1、3、および 5 をグループ化する
Set myGroup = Worksheets("Sheet1").DrawingObjects(Array(1, 3, 5)).Group Worksheets("Sheet1").Activate myGroup.Select |
|||||||||
| ご意見・ご感想をお寄せください。info@beagle-hc.com ‖ このサイトについて | |||||||||
| Copyright 2006 - 2009 uTRAM Corp. All Rights Reserved | |||||||||