PC Review


Reply
Thread Tools Rate Thread

Changing chart data ranges from VBA code

 
 
Andrew
Guest
Posts: n/a
 
      11th Dec 2007
Hello,
I have a VBA program which will be generating a lot of data, and I
want to be able to view the data on a chart. The chart only holds
32000 samples, and my program is likely to generate 100,000 samples.
So, I start out with the source data range being fixed at R1C2 to
R32001C2. But when I get to a count of 31000 samples, I want the data
range to shift up by 1000 rows, so that the new data range would be
R1001C2 to R33000C2. And I want this process to repeat for every 1000
samples. Can someone please send me a snippet of code to perform this
task.

Here is my starting code.

Dim datacount as double
If datacount > 31000 And datacount Mod 1000 = 0 Then

With Worksheets("monitor").ChartObjects(1).Chart
.SeriesCollection(1).XValues = "=data!R1C2:R32000C2"
.SeriesCollection(1).Values = "=data!R1C4:R32000C4"
End with
End If


thanks,
Andy

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      11th Dec 2007
for i=1 to 60000 step 1000
do it
next i

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Andrew" <(E-Mail Removed)> wrote in message
news:864871ab-35f1-4255-b6fc-(E-Mail Removed)...
> Hello,
> I have a VBA program which will be generating a lot of data, and I
> want to be able to view the data on a chart. The chart only holds
> 32000 samples, and my program is likely to generate 100,000 samples.
> So, I start out with the source data range being fixed at R1C2 to
> R32001C2. But when I get to a count of 31000 samples, I want the data
> range to shift up by 1000 rows, so that the new data range would be
> R1001C2 to R33000C2. And I want this process to repeat for every 1000
> samples. Can someone please send me a snippet of code to perform this
> task.
>
> Here is my starting code.
>
> Dim datacount as double
> If datacount > 31000 And datacount Mod 1000 = 0 Then
>
> With Worksheets("monitor").ChartObjects(1).Chart
> .SeriesCollection(1).XValues = "=data!R1C2:R32000C2"
> .SeriesCollection(1).Values = "=data!R1C4:R32000C4"
> End with
> End If
>
>
> thanks,
> Andy
>


 
Reply With Quote
 
Andrew
Guest
Posts: n/a
 
      11th Dec 2007
On Dec 11, 11:35 am, "Don Guillett" <dguille...@austin.rr.com> wrote:
> for i=1 to 60000 step 1000
> do it
> next i
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguille...@austin.rr.com"Andrew" <andrewkgent...@gmail.com> wrote in message
>
> news:864871ab-35f1-4255-b6fc-(E-Mail Removed)...
>
> > Hello,
> > I have a VBA program which will be generating a lot of data, and I
> > want to be able to view the data on a chart. The chart only holds
> > 32000 samples, and my program is likely to generate 100,000 samples.
> > So, I start out with the source data range being fixed at R1C2 to
> > R32001C2. But when I get to a count of 31000 samples, I want the data
> > range to shift up by 1000 rows, so that the new data range would be
> > R1001C2 to R33000C2. And I want this process to repeat for every 1000
> > samples. Can someone please send me a snippet of code to perform this
> > task.

>
> > Here is my starting code.

>
> > Dim datacount as double
> > If datacount > 31000 And datacount Mod 1000 = 0 Then

>
> > With Worksheets("monitor").ChartObjects(1).Chart
> > .SeriesCollection(1).XValues = "=data!R1C2:R32000C2"
> > .SeriesCollection(1).Values = "=data!R1C4:R32000C4"
> > End with
> > End If

>
> > thanks,
> > Andy


I apologize for poorly describing my question. I know how to create
the loop to find the multiples of 1000. What I don't know is how to
enter "=data!R1C2:R32000C2" in the form of a variable.
 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      12th Dec 2007
You can do this just as easily and more automatically using defined names as
your chart data source, rather than VBA. Here is where to read about dynamic
charts:

http://peltiertech.com/Excel/Charts/Dynamics.html

In particular, you need a minor variation on this technique, which plots the
last twelve months from a longer table:

http://peltiertech.com/Excel/Charts/DynamicLast12.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Andrew" <(E-Mail Removed)> wrote in message
news:864871ab-35f1-4255-b6fc-(E-Mail Removed)...
> Hello,
> I have a VBA program which will be generating a lot of data, and I
> want to be able to view the data on a chart. The chart only holds
> 32000 samples, and my program is likely to generate 100,000 samples.
> So, I start out with the source data range being fixed at R1C2 to
> R32001C2. But when I get to a count of 31000 samples, I want the data
> range to shift up by 1000 rows, so that the new data range would be
> R1001C2 to R33000C2. And I want this process to repeat for every 1000
> samples. Can someone please send me a snippet of code to perform this
> task.
>
> Here is my starting code.
>
> Dim datacount as double
> If datacount > 31000 And datacount Mod 1000 = 0 Then
>
> With Worksheets("monitor").ChartObjects(1).Chart
> .SeriesCollection(1).XValues = "=data!R1C2:R32000C2"
> .SeriesCollection(1).Values = "=data!R1C4:R32000C4"
> End with
> End If
>
>
> thanks,
> Andy
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart data ranges Alan Microsoft Excel Programming 3 20th Mar 2007 07:43 PM
Dynamic chart: Changing Ranges =?Utf-8?B?QmVuaWhpbWU=?= Microsoft Excel Charting 2 28th Apr 2006 12:20 AM
Chart Data Ranges Joyce Microsoft Excel Charting 2 8th Oct 2004 09:54 PM
Changing a chart source data in code. JimPNicholls Microsoft Excel Programming 1 7th May 2004 03:57 PM
Chart Source Data Ranges Changing when Data Sheet updated from text file source. Tekn0 Microsoft Excel Charting 3 8th Jan 2004 04:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:14 PM.