I am relatively new to VBA and I am having trouble updating the sourecdata for a chart in VBA. Recording a macro for it yeilded:
Sheets("Rating Chart").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("Summary").Range("AA2:AB61"), _
PlotBy:=xlColumns
I want to dynamically determine how many rows of data I have and update the source range accordinly.
I locate the last row of data using:
FinalRow = Sheets("Summary").Cells(Rows.Count, 27).End(xlUp).Row
I then try to update the source range using the following:
ActiveChart.SetSourceData _
Source:=Sheets("Summary").Range(Cells(2, 27), Cells(FinalRow, 28)), _
PlotBy:=xlColumns
Using the Cells in the Range seems to be my problem but I don't know how to vary the range any other way. Any help would be greatly appreciated. Thank you.
Sheets("Rating Chart").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("Summary").Range("AA2:AB61"), _
PlotBy:=xlColumns
I want to dynamically determine how many rows of data I have and update the source range accordinly.
I locate the last row of data using:
FinalRow = Sheets("Summary").Cells(Rows.Count, 27).End(xlUp).Row
I then try to update the source range using the following:
ActiveChart.SetSourceData _
Source:=Sheets("Summary").Range(Cells(2, 27), Cells(FinalRow, 28)), _
PlotBy:=xlColumns
Using the Cells in the Range seems to be my problem but I don't know how to vary the range any other way. Any help would be greatly appreciated. Thank you.