|
データのあるシートを仮に Sheet1 として、ブックの先頭に グラフ という名前の
シートを追加し、そこへ上からグラフを並べるコードです。
Sub Mk_Charts()
Dim i As Long, j As Long
Dim Sh As Worksheet
Dim Ch As ChartObject
Dim MyR As Range, GR As Range
j = 2: Application.ScreenUpdating = False
Set Sh = Worksheets.Add(Before:=Worksheets(1))
Sh.Name = "グラフ": ActiveWindow.DisplayGridlines = False
With Worksheets("Sheet1").Range("A1").CurrentRegion
For i = 2 To .Columns.Count
Set MyR = Union(.Columns(1), .Columns(i))
Set GR = Sh.Cells(j, 2).Resize(20, 8)
Set Ch = Sh.ChartObjects _
.Add(GR.Left, GR.Top, GR.Width, GR.Height)
Ch.Chart.ChartType = xlXYScatterLinesNoMarkers
Ch.Chart.SetSourceData MyR
Ch.Chart.HasLegend = False
Set MyR = Nothing: Set GR = Nothing: Set Ch = Nothing
j = j + 21
Next i
End With
Application.ScreenUpdating = True: Set Sh = Nothing
End Sub
|
|