Searched but could not find resolution, please help if possible.
I am trying to create a macro that will graph series or ranges that is declared. The need to declare the range comes from the fact that the source sheet is updated and grows by the day therefore I cannot write a code using fixed a data range, or else the graph won't update.
I'm having problems with the last line.Code:Dim LastRow As Integer Dim RNG1 As Range, RNG2 As Range, RNG3 As Range Sheets("Summary").Select LastRow = Range("B65536").End(xlUp).Row Set RNG1 = Range(Cells(LastRow - 90, 2), Cells(LastRow, 2)) Set RNG2 = Range(Cells(LastRow - 90, 10), Cells(LastRow, 10)) Set RNG3 = Range(Cells(LastRow - 90, 12), Cells(LastRow, 12)) Charts.Add ActiveChart.ChartType = xlArea ActiveChart.SetSourceData Source:=Range("RNG1, RNG2, RNG3"), PlotBy:=xlColumns
The code is supposed to identify the last row and use the 90 data points leading up to the last row to create a series graph.
Thanks for your help in advance!!
Maybe you may try to use dynamic named ranges (eg. if you want to select the 90 last cells of columns B, use the following formula) :
there must be no empty cells between the first used cell and the last used cell of the column.
Then you can use the named ranges into the chart in lieu of ranges.
Auto Merged Post Until 24 Hrs Passes;
To correct your syntax :
DanielCode:ActiveChart.SetSourceData Source:=Union(RNG1, RNG2, RNG3), PlotBy:=xlColumns
Last edited by Dave Hawley; May 17th, 2008 at 09:26.
There are currently 1 users browsing this thread. (0 members and 1 guests)