A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Charts and Charting
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Change Source Data in VBA



 
 
Thread Tools Display Modes
  #1  
Old November 9th, 2009, 02:24 PM posted to microsoft.public.excel.charting
Risky Dave
external usenet poster
 
Posts: 28
Default Change Source Data in VBA

Hi,

Please be aware that I have also posted this in the XL Programming group as
I am not sure which is most appropriate.

I have a chart set up (eg a simple bar chart) that I want to be able to
update automatically using VBA. The source data will vary in quantity and I
have no way of knowing in advance how many data there will be.
Eg
I might currently have:
A1 B1 C1 D1
10 12 15 35

but when I want to refresh the chart I might have:
A1 B1 C1 D1 E1 F1
15 5 10 20 25 10

(don't worry about the actual values).

How do I tell Excel to re-size the source data area automatically (ie as
part of a VBA macro) - the number of data may reduce as well as increase?

I'm reasonalby comfortable with VBA but by no means am I a programmer, so a
brief explanation of how the solution works would be appreciated.

This is in Office 2003 if that makes a difference.

TIA

Dave

  #2  
Old November 9th, 2009, 02:38 PM posted to microsoft.public.excel.charting
Luke M
external usenet poster
 
Posts: 2,672
Default Change Source Data in VBA

Before tackling this process using VBA, would it be possible to solve with a
dynamic range?
http://peltiertech.com/Excel/Charts/Dynamics.html

In your scenario, perhaps a range defined something like:
=OFFSET($A$1,0,0,COUNT(1:1),1)
named "MyRange"

In your chart, the data range is:
='My Book.xls'!MyRange



--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Risky Dave" wrote:

Hi,

Please be aware that I have also posted this in the XL Programming group as
I am not sure which is most appropriate.

I have a chart set up (eg a simple bar chart) that I want to be able to
update automatically using VBA. The source data will vary in quantity and I
have no way of knowing in advance how many data there will be.
Eg
I might currently have:
A1 B1 C1 D1
10 12 15 35

but when I want to refresh the chart I might have:
A1 B1 C1 D1 E1 F1
15 5 10 20 25 10

(don't worry about the actual values).

How do I tell Excel to re-size the source data area automatically (ie as
part of a VBA macro) - the number of data may reduce as well as increase?

I'm reasonalby comfortable with VBA but by no means am I a programmer, so a
brief explanation of how the solution works would be appreciated.

This is in Office 2003 if that makes a difference.

TIA

Dave

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.