複数範囲選択のグラフを作成

Visual Basic for Applications

Sub Macro()
  '本サンプルでは列番号1,16,17,19,20を選択して折線グラフを作成
  Dim Sheet As Integer
  Dim EndRow As Integer
  Sheet = 1
  EndRow = Worksheets(Sheet).Cells(1, 1).End(xlDown).Row
  Union(Range(Cells(1, 1), Cells(EndRow, 1)), Range(Cells(1, 16), Cells(EndRow, 17)), Range(Cells(1, 19), Cells(EndRow, 20))).Select
  ActiveSheet.Shapes.AddChart.Select
  ActiveChart.ChartType = xlLine
End Sub