Hello,
I'm creating a chart in a macro using the code:
Dim Cht As Chart
Set Cht = Application.Charts.Add
With Cht
.ChartType = xlXYScatter
.SetSourceData Source:=Sheets("2-1").Range(????), PlotBy:=xlColumns
.Location Where:=xlLocationAsObject, Name:="2-1"
End With
The ???? is there because I need to know how to use a range of cells in non-adjacent columns. Specifically, my x data is in column F, and my y data is in column D.
Furthermore, I intend to use this macro on many, many data sets. Columns F and D will have the same number of entries on a given sheet, but each sheet will have a different number of entries.
Can anyone tell me how to enter this range?
Thank you,
-DanExcel
I'm creating a chart in a macro using the code:
Dim Cht As Chart
Set Cht = Application.Charts.Add
With Cht
.ChartType = xlXYScatter
.SetSourceData Source:=Sheets("2-1").Range(????), PlotBy:=xlColumns
.Location Where:=xlLocationAsObject, Name:="2-1"
End With
The ???? is there because I need to know how to use a range of cells in non-adjacent columns. Specifically, my x data is in column F, and my y data is in column D.
Furthermore, I intend to use this macro on many, many data sets. Columns F and D will have the same number of entries on a given sheet, but each sheet will have a different number of entries.
Can anyone tell me how to enter this range?
Thank you,
-DanExcel