LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 22
Default Chart Object source data problem

I am having a problem editing an excel template which I managed to cobble
together a while back.

The template is a dashboard report. It contains one specimen of a dashboard
for one store.

The way it works is that for each store being reported on, the range
containing the specimen is copied and pasted. At the end of that proccess
(maybe hundreds of dashboards), 8 chart objects in each dashboard are
connected to their source data:

i = 9
x = conRows '33
On Error GoTo OuttaHere
Do
'Link the charts to their source data:
For y = 0 To 7
shtRpt.ChartObjects(i + y).Activate
XLobj.ActiveChart.SetSourceData _
Source:=XLobj.Sheets("StoreReports").Range(shtRpt. Cells(x + (2 *
y), conCols - 5), _
shtRpt.Cells(x + 1 + (2 * y), conCols)), PlotBy:=xlRows
Next y
i = i + 8
x = x + conRows
Loop

I've been running this code for months and it works like a charm, although I
had to wrestle the template to the ground and beat it into submission,
rearranging the charts until they were in the order that Excel insisted they
be. Before I rearranged them, they were all out of position with regard to
their source data.

OK, so this works fine. But now, I'm required to add 2 more charts. So I
copied and pasted the bottom 2 of the 8 charts below themselves and now have
10 charts. I changed the above code to:

For y = 0 To 9

Unfortunately, the range Excel selects for my 2 new charts using the above
loop was not the data that had been added below the ranges for the other 8
charts (8 2-row data ranges, neatly listed in a 16 row by 5 column range, now
increased to 10 2-row data ranges neatly listed in a 20 row by 5 column range
to the right of the dashboard, out of the print area). Instead of linking to
those 2 new sources (R17C26:R18C31) and (R19C26:R20C31), my new graphs linked
instead to the empty ranges (R35C26:R36C31) and (R33C26:R34C31), which are
not only empty and below the dashboard's range (such that these 2 graphs for
this store would actually find themselves linked to data from the next
store's dashboard), but the order is reversed. The graph on the left should
be linked to the higher positioned data, R33, not R35, if the code was
cycling through the graphs in order. I can find no way to accurately identify
or rename the graphs. I only hit on the successful 8 graph solution after
days of trial and error (I have no idea why it works!).

I have a function that returns the names of the graphs in my immediate window:


Sub ChartNames()
Dim CO As ChartObject
Dim n As Integer

For Each CO In Sheets("Template").ChartObjects
Debug.Print CO.Name
Next CO

End Sub

When I run it for my new template, I get the following list:

Chart 1
Chart 2
Chart 3
Chart 4
Chart 5
Chart 6
Chart 7
Chart 8
Chart 7
Chart 1

How is it that duplicate names are even possible?! This is really mind-
numbing!

Please help!

Thanks,

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...chart/200805/1

 
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
pie chart & column chart w/same source data martymi Charts and Charting in Excel 2 May 1st 07 04:25 PM
How do you link chart source data when you copy the chart? mamagirl Charts and Charting in Excel 1 December 8th 06 02:40 AM
Chart/Source Data update problem Rich Charts and Charting in Excel 1 July 4th 05 04:35 PM
Find and replace data in an Excel chart object Cawen Charts and Charting in Excel 2 March 31st 05 06:47 PM
Excel 97 chart opened in Excel 2003 - Source Data problem DHunt Charts and Charting in Excel 0 December 6th 04 08:05 PM


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

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"