Hi, I have a question about creating graphs to Excel sheets programatically. In my app, when user clicks a button, a report(summary of numbers) is generated, and I would like to add a graph below the report.
I don't know the right syntax for dynamically specifying .XValues, .Values, and .Name. I tried the following, but it didn't work.
ActiveChart.SeriesCollection(1).XValues = "=Sheets("Summary Report"
.Range(Cells(iRow,10), Cells(iRow,iCount))"
Please help! Thank you,
____________________________________________
iCount = 10
iRow = 1
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=wBudgetCatRpt.Range("A16"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=wBudgetCatRpt.Range(Cells(iRow,10), Cells(iRow,iCount))"
ActiveChart.SeriesCollection(1).Values = "='Summary Report'!R10C2:R13C2"
ActiveChart.SeriesCollection(1).Name = "='Summary Report'!R9C2"
''comment: add more series here
ActiveChart.Location Where:=xlLocationAsObject, Name:="Summary Report"
I don't know the right syntax for dynamically specifying .XValues, .Values, and .Name. I tried the following, but it didn't work.
ActiveChart.SeriesCollection(1).XValues = "=Sheets("Summary Report"
Please help! Thank you,
____________________________________________
iCount = 10
iRow = 1
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=wBudgetCatRpt.Range("A16"
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "=wBudgetCatRpt.Range(Cells(iRow,10), Cells(iRow,iCount))"
ActiveChart.SeriesCollection(1).Values = "='Summary Report'!R10C2:R13C2"
ActiveChart.SeriesCollection(1).Name = "='Summary Report'!R9C2"
''comment: add more series here
ActiveChart.Location Where:=xlLocationAsObject, Name:="Summary Report"