Hi everyone,
I'm having an issue with my macro. Here is my question.
In excel say you want to make a graph and you have range say B9:B20 can you make that range variable on the values of another cell?
So in Bx:By it would determing the range of the graph (x and y) based on cells H and I
Something like this
Range("B" & Range("H9") & ":B" & Range("I9") & ",D9" & Range("H9") & ":D" & Range("I9")), PlotBy:=xlColumns
Thank you,
George
My code:
Range("B" & Range("H9") & ":B" & Range("I9") & ",D" & Range("H9") & ":D" & Range("I9")).Select
Range("D" & Range("H9")).Activate
Charts.Add
ActiveChart.ChartType = xlLineStacked
ActiveChart.SetSourceData Source:=Sheets("report.xls"). _
Range("B" & Range("H9") & ":B" & Range("I9") & ",D9" & Range("H9") & ":D" & Range("I9")), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:= _
"report.xls"
ActiveChart.Legend.Select
Selection.Delete
ActiveChart.Axes(xlCategory).Select
ActiveChart.PlotArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Newspaper Advertising"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Amount"
End With
Bookmarks