Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Updating a chart

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Khurram - 25 Jan 2007 08:29 GMT
Hi all,
I'm using the following code for updating a chart on an existing
worksheet.  The chart contains data covering a period of 13 months
(Jan-Jan) and the code prior to this adds an extra month's worth of
data to the source.  What I need is for the update process to drop one
month at the begining when a new month is added.  The below code ends
up taking everything is the rows rather than the specific range I'm
trying to use.  I think I'm making a trivial mistake somewhere but I
cant locate it.  Please help.

Dim bottomRightOfGraphData As String
Dim topLeftOfGraphData As String

bottomRightOfGraphData = ActiveCell.Address
Range(bottomRightOfGraphData).Select
ActiveCell.Offset(-1, -12).Select
topLeftOfGraphData = ActiveCell.Address

'update related graph
ActiveSheet.ChartObjects("Chart 8").Activate
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("HP Analyst & Q
time").Range("A1:A3", topLeftOfGraphData & ":" &
bottomRightOfGraphData), PlotBy:=xlRows

Thank you kindly
Deecrypt
Jon Peltier - 25 Jan 2007 14:44 GMT
Are you deleting cells during the process, or just changing the range
pointed at by the chart? If it's the latter, make a dynamic chart, which
does not require VBA coding:

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

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

> Hi all,
> I'm using the following code for updating a chart on an existing
[quoted text clipped - 23 lines]
> Thank you kindly
> Deecrypt
Khurram - 26 Jan 2007 09:14 GMT
Hi Jon,
Thank you for your help.  Unfortunately I did need to use VBA but
thankfully I managed to sort the problem out.  It was to do with the
following statement.

ActiveChart.SetSourceData Source:=Sheets("HP Analyst & Q
time").Range("A1:A3", topLeftOfGraphData & ":" &
bottomRightOfGraphData), PlotBy:=xlRows

As I had gathered, I was making a trivial mistake and solution required
changes in the "Range" part of the statement where I simply moved the
last of first set of double quotes past the comma and added an "&"
symbol next to the variable "topLeftOfGraphData".  The statement now
looks like this.

ActiveChart.SetSourceData Source:=Sheets("HP Analyst & Q
time").Range("A1:A3," & topLeftOfGraphData & ":" &
bottomRightOfGraphData), PlotBy:=xlRows

Thank you kindly
Khurram

Khurram

On Jan 25, 2:44 pm, "Jon Peltier" <jonxlmv...@SPAMpeltiertech.com>
wrote:
> Are you deleting cells during the process, or just changing the range
> pointed at by the chart? If it's the latter, make a dynamic chart, which
[quoted text clipped - 35 lines]
> > Thank you kindly
> > Deecrypt- Hide quoted text -- Show quoted text -
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.