Elvis
05-31-2009, 11:02 AM
Hi,
I have the macro below that I've created to update chart ranges based on whenever new data/observations for the series become avaliable.
However I have several charts (20) on the worksheet which I need to do this for. How easy would it be to develop a macro to loop through each chart and update the series?
Is there a way to check what column in terms of the series each chartis referencing and then running a modified version of the code below based on that column? For example in the macro below, the seriescollection(1) is referencing column 28. Instead I'd like to loop through each chart, determine what column is being referenced for that chart and then update the chart range accordingly based on the last populated row found.
Thanks,
Elvis
Sub chartupdate3()
lastcell = Cells(1075, 28).End(xlDown).Row 'finds last populated cell
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Values = Worksheets("Table").Range("AB979:AB" & lastcell)
ActiveChart.SeriesCollection(1).XValues = Worksheets("Table").Range("A979:A" & lastcell)
End Sub
I have the macro below that I've created to update chart ranges based on whenever new data/observations for the series become avaliable.
However I have several charts (20) on the worksheet which I need to do this for. How easy would it be to develop a macro to loop through each chart and update the series?
Is there a way to check what column in terms of the series each chartis referencing and then running a modified version of the code below based on that column? For example in the macro below, the seriescollection(1) is referencing column 28. Instead I'd like to loop through each chart, determine what column is being referenced for that chart and then update the chart range accordingly based on the last populated row found.
Thanks,
Elvis
Sub chartupdate3()
lastcell = Cells(1075, 28).End(xlDown).Row 'finds last populated cell
ActiveSheet.ChartObjects("Chart 17").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Values = Worksheets("Table").Range("AB979:AB" & lastcell)
ActiveChart.SeriesCollection(1).XValues = Worksheets("Table").Range("A979:A" & lastcell)
End Sub