0
VBAを使用して動的XYscatterチャートの生成を自動化しようとしています。私のデータは、試行ごとに12個のデータのセットに入っており、試行回数はさまざまです。まず、csvファイルをスキャンして最後のデータセットを探し、タグの最初の行を削除して、12で割り、使用可能なセット数を決定し、データを対応するデータポイントでグラフに取り込み、シリーズ名。ほとんどのコードが動作していますが、シリーズ名の範囲データを含める際に構文上の問題があります。シリーズ名は、列データの範囲ではなく列を選択している場合にのみ機能します。複数の列入力をXYscatterチャートとして持つExcel VBA動的生成チャートのシリーズ名
シリーズ名として複数の列を入力するようにコードを変更するにはどうすればよいですか?
Sub PlotSelect()
Dim myChart As Chart
DataRow = 1
SelectRow = 2
With ActiveSheet
'To count the number of rows to determine number of sets of data
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Row = LastRow - 1
N = Row/12
'Creating a dummy chart before repopulating the data points
Range("A1:B2").Select
Set myChart = ActiveSheet.Shapes.AddChart2(240, xlXYScatterSmooth).Chart
' delete all the dummy series
For i = myChart.SeriesCollection.Count To 1 Step -1
myChart.SeriesCollection(i).Delete
Next
'Populating chart with data
Do While DataRow <= N
If DataRow <> -1 Then
myChart.SeriesCollection.NewSeries
myChart.SeriesCollection(DataRow).Name = Range(ActiveSheet.Cells(SelectRow, 2), ActiveSheet.Cells(SelectRow, 5))
myChart.SeriesCollection(DataRow).Values = Range(ActiveSheet.Cells(SelectRow, 9), ActiveSheet.Cells(SelectRow + 11, 9))
myChart.SeriesCollection(DataRow).XValues = Range(ActiveSheet.Cells(SelectRow, 8), ActiveSheet.Cells(SelectRow + 11, 8))
End If
DataRow = DataRow + 1
SelectRow = SelectRow + 12
Loop
End Sub