質問: names Next End Sub ```
回答: で、できた・・・ Sub GrapfGS() Dim op As Worksheet, sn As Worksheet, i As Integer, names As String, xname As String Dim cht As ChartObject Dim rng As Range Dim chart1 As Chart Set op = Workbooks("CAB-Grapf.xls").ActiveSheet Application.ScreenUpdating = False 'グラフ作成 Set cht = ActiveSheet.ChartObjects.Add(100, 100, 350, 260) cht.Chart.ChartType = xlXYScatterSmoothNoMarkers cht.Name = "G-S" cht.Top = Range("H4").Top cht.Left = Range("H4").Left cht.Chart.Axes(xlValue).MinimumScaleIsAuto = True cht.Chart.Axes(xlValue).MaximumScaleIsAuto = True cht.Chart.Axes(xlCategory).MaximumScale = 300 cht.Chart.Axes(xlCategory).MinimumScale = 0 cht.Chart.Legend.IncludeInLayout = False cht.Chart.Legend.Position = xlLegendPositionCorner cht.Chart.Legend.Format.Fill.ForeColor.ObjectThemeColor = msoThemeColorBackground1 cht.Chart.Axes(xlValue).TickLabels.NumberFormatLocal = General cht.Chart.Axes(xlCategory).TickLabels.NumberFormatLocal = General cht.Chart.HasTitle = True cht.Chart.ChartTitle.Text = "G-S" 'データ取得ループ For i = 1 To Worksheets(1).Range("H1").Value If i > 10 Then MsgBox "データーがそんなにないよ(V)o¥o(V)" Exit For End If With Worksheets(2 + i) 'データ範囲の取得 If i = 1 Then '初回は見出し列も取得 cht.Chart.SetSourceData Source:=.Range("T1014:T3014, N1014:N3014") cht.Chart.SeriesCollection(1).XValues = .Range("T1014:T3014") cht.Chart.SeriesCollection(1).Values = .Range("N1014:N3014") Else '2回目以降はデータ系列を追加 Set rng = .Range("N1014:N3014") cht.Chart.SeriesCollection.Add rng End If End With 'グラフの名前をDATAシートから取得>Grapfシートを選択して貼り付け。 names = Worksheets(1).Range("B" & i + 1).Value Worksheets(2).Select cht.Chart.SeriesCollection(i).Name = names Next End Sub