LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default dynamic chart range with VBA

I have been spending a lot of time trying to figure out dynamic chart
ranges and just can't figure it out. I have a chart (scatter plot)
that needs to have the X and Y values of a series linked to the number
of values present, which will be constantly changing. It would also be
nice to have the maximum/minimum scale adjustable as well, for both
axes. the code I am using (below) is causing errors.

Private Sub UpdateChart()
span = Sheets("sheet1").Range("C4").Value * 12
stepsize = Sheets("sheet1").Range("C6").Value * 12
Set CurrentChart = Sheets("sheet2").ChartObjects(1).Chart
CurrentChart.Parent.Width = 450
CurrentChart.Parent.Height = 150

'ActiveChart.SeriesCollection(1).XValues = "=Sheet2!R2C2:R2C" & 2
+_
(span / stepsize) & ""
'ActiveChart.SeriesCollection(1).Values = "=Sheet2!R1C2:R1C" & 2 +
_
(span / stepsize) & ""

ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScale = 0
.MaximumScale = span / stepsize + 1
.MinorUnit = 12
.MajorUnit = 24
.Crosses = 0
End With

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"

' Show the chart
Image3.Picture = LoadPicture(Fname)
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic range and chart - big help!! Xaraam Excel Worksheet Functions 3 August 4th 08 12:01 PM
Chart empty with new data in the dynamic range chart. Feejo Excel Discussion (Misc queries) 16 January 3rd 08 10:03 PM
Dynamic Chart Range Chuck Taylor Excel Programming 2 July 24th 05 06:30 AM
Dynamic Range Chart ??? Yogalete Charts and Charting in Excel 3 April 27th 05 11:51 PM
Dynamic Chart Range and Chart Update ExcelMonkey[_154_] Excel Programming 1 July 6th 04 08:26 PM


All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"