I have recorded this macro. It’s for inserting a chart. How can I create a chart shape and a sign it to a variable for later reference? I want to pass a variable to the range. I just want to change the (52) number. So if the variable is row how can I use it in the following code. I tried this
("'Simpson'!$K$3:$L$row")
But it doesn’t work
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Simpson'!$K$3:$L$52")
ActiveChart.ChartType = xlXYScatterSmooth
ActiveChart.ChartTitle.Select
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.ChartTitle.Text = "integrated function chart"
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.SetElement (msoElementPrimaryValueAxisTitleHorizontal)
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.Axes(xlValue, xlPrimary).AxisTitle.Text = "x values"
ActiveSheet.ChartObjects("Chart 5""""").Activate
'How can I delete the legend in one. combining the next two
ActiveChart.Legend.Select
Selection.Delete
Try this