Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Updating a chart

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Updating a chart

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
_______


"Khurram" wrote in message
ups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Updating a chart

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"
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
does not require VBA coding:

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

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

"Khurram" wrote in oglegroups.com...



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- Hide quoted text -- Show quoted text -


Reply
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
Chart not updating shannon c Charts and Charting in Excel 3 October 15th 10 12:25 PM
Updating A Chart ? Robert11[_3_] Charts and Charting in Excel 2 July 10th 09 08:46 PM
Updating a chart Ian Belcher Charts and Charting in Excel 0 October 23rd 06 04:38 PM
Updating Chart Stan Charts and Charting in Excel 0 June 12th 06 03:17 AM
chart updating Nick Excel Programming 2 January 30th 04 08:58 PM


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

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

About Us

"It's about Microsoft Excel"