T
Tino
Below is part of a macro to make a chart. I am running the macro in a
workbook with a single sheet in it. The macro runs correctly. However
"ActiveChart.SetSourceData" and "ActiveChart.Location" both refer to the
sheet by name. Instead of using the sheet name I would like to be able to
just refer to the sheet number, as I can do with "ChartTitle.Characters.Text
". I tried modifying both lines as shown below but both failed:
ActiveChart.SetSourceData" failed with "Object doesn't support this property
or method"
and
"ActiveChart.Location" failed with "Invalid procedure call or argument"
Is there a problem with the way I am referring to sheet(1) or is there
another way to be able to make the chart and store the chart in sheet(1)?
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData
Source:=Sheets("QC_rad_pos_2").Range("D8:E200"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="QC_rad_pos_2"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = Sheets(1).Range("A1").Text
End With
ActiveChart.SetSourceData Source:=Sheets(1).Range("D8:E200"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=Sheets(1)
regards
Peter
workbook with a single sheet in it. The macro runs correctly. However
"ActiveChart.SetSourceData" and "ActiveChart.Location" both refer to the
sheet by name. Instead of using the sheet name I would like to be able to
just refer to the sheet number, as I can do with "ChartTitle.Characters.Text
". I tried modifying both lines as shown below but both failed:
ActiveChart.SetSourceData" failed with "Object doesn't support this property
or method"
and
"ActiveChart.Location" failed with "Invalid procedure call or argument"
Is there a problem with the way I am referring to sheet(1) or is there
another way to be able to make the chart and store the chart in sheet(1)?
Charts.Add
ActiveChart.ChartType = xlXYScatter
ActiveChart.SetSourceData
Source:=Sheets("QC_rad_pos_2").Range("D8:E200"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="QC_rad_pos_2"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = Sheets(1).Range("A1").Text
End With
ActiveChart.SetSourceData Source:=Sheets(1).Range("D8:E200"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:=Sheets(1)
regards
Peter