PDA

View Full Version : Solved: Using a range in a chart with VBA



WebGuy
05-25-2007, 04:27 AM
Hi !

I am trying to create a chart that grows as the range that it's based on grows.
I have a set of data that starts at F2 and grows (f3, f4..). Now, what i want to do is to make the chart grow with the range.
I got the graph working fine, buti can only set it to a fixed range.
The graph is redrawn everytime a new value is added.


Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet2").Range("F2:F25"), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Flextid"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.HasLegend = False
With Selection.Border
.ColorIndex = 2
.Weight = 2
.LineStyle = 1
End With
With Selection.Interior
.ColorIndex = 2
.PatternColorIndex = 56
.Pattern = 1
End With
Range("A9").Select


Is it possible to make a dynamic graph like that ? How do i do it ?
Thanks!

Bob Phillips
05-25-2007, 04:57 AM
Take a look at http://www.j-walk.com/ss/excel/tips/tip83.htm

WebGuy
05-25-2007, 06:10 AM
Thanks a lot!