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  

Charting error in Excel2003



 
 
Thread Tools Display Modes
  #1  
Old October 19th, 2005, 08:40 PM
Julie
external usenet poster
 
Posts: n/a
Default Charting error in Excel2003

I have the following segment of code within a larger method that worked
just fine on Excel 97, but now on Excel 2003, I get a "run-time error
'1004' Method 'PlotBy' of '_Chart' failed" on ActiveChart.PlotBy =
xlColumns. I can comment that line out, but I am not sure if I am
affecting anything else. Does anyone know why this would no longer
work in Excel 2003?

Dim r1 As Range, r2 As Range, myMultiAreaRange As Range
Worksheets("NatureOfInjuryChart").Activate
Set r1 = Range("A5",
Worksheets("NatureOfInjuryChart").Range("A5").End( xlDown))
Set r2 = Range("C5",
Worksheets("NatureOfInjuryChart").Range("C5").End( xlDown))
Set myMultiAreaRange = Union(r1, r2)

myMultiAreaRange.Select
Range("C5").Activate

Charts.Add
ActiveChart.ChartType = xl3DPie
ActiveChart.PlotBy = xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:="NatureOfInjuryChart"

#2 Also, this chart (from above) is on the same worksheet as another
chart that is using the range below (columns A & B). However the
calculations for the chart above are exactly the same as the chart
below on Excel 2003, but reflect correct percentages in Excel 97. Does
anyone know why this chart is not producing correct percentages now in
2003?

Range("A5",
Worksheets("NatureOfInjuryChart").Range("B5").End( xlDown)).Select
Range("A5").Activate
Charts.Add
ActiveChart.ChartType = xl3DPie
'ActiveChart.PlotBy = xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:="NatureOfInjuryChart"

This is really stumping me. Any help is greatly appreciated.
Julie

  #2  
Old October 19th, 2005, 11:42 PM
Jon Peltier
external usenet poster
 
Posts: n/a
Default Charting error in Excel2003

Julie -

1. Did you get a similar chart when you omitted the ActiveChart.PlotBy
line? I would expect that you did. The macro recorder leaves lots of
unnecessary junk in the recorded code.

2. If you increase the decimal digits, do the percentages come out
right? Someone at Microsoft decided it was better to coerce the total to
100%, rather than correctly round the individual values. In a simple
example, three equal wedges are 33.3%, but Excel will show them as 33%,
33%, and 34% if you don't allow extra digits. I had one example last
year in which one percentage label was increased by around 2 percentage
points!

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

Julie wrote:

I have the following segment of code within a larger method that worked
just fine on Excel 97, but now on Excel 2003, I get a "run-time error
'1004' Method 'PlotBy' of '_Chart' failed" on ActiveChart.PlotBy =
xlColumns. I can comment that line out, but I am not sure if I am
affecting anything else. Does anyone know why this would no longer
work in Excel 2003?

Dim r1 As Range, r2 As Range, myMultiAreaRange As Range
Worksheets("NatureOfInjuryChart").Activate
Set r1 = Range("A5",
Worksheets("NatureOfInjuryChart").Range("A5").End( xlDown))
Set r2 = Range("C5",
Worksheets("NatureOfInjuryChart").Range("C5").End( xlDown))
Set myMultiAreaRange = Union(r1, r2)

myMultiAreaRange.Select
Range("C5").Activate

Charts.Add
ActiveChart.ChartType = xl3DPie
ActiveChart.PlotBy = xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:="NatureOfInjuryChart"

#2 Also, this chart (from above) is on the same worksheet as another
chart that is using the range below (columns A & B). However the
calculations for the chart above are exactly the same as the chart
below on Excel 2003, but reflect correct percentages in Excel 97. Does
anyone know why this chart is not producing correct percentages now in
2003?

Range("A5",
Worksheets("NatureOfInjuryChart").Range("B5").End( xlDown)).Select
Range("A5").Activate
Charts.Add
ActiveChart.ChartType = xl3DPie
'ActiveChart.PlotBy = xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:="NatureOfInjuryChart"

This is really stumping me. Any help is greatly appreciated.
Julie

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
MS-Query code from EXCEL97 doesn't work in EXCEL2003 ?? ln54 General Discussion 4 February 21st, 2005 08:12 PM
Dynamic charting problems (events) [email protected] Charts and Charting 4 January 27th, 2005 09:32 PM
Charting time? help please... Gustavo Monteverde Charts and Charting 1 November 28th, 2004 04:53 AM
Interactive Charting KG Charts and Charting 4 November 9th, 2004 12:38 PM
Interesting Web blog on Excel charting obsessions Eva Whitley Charts and Charting 1 May 19th, 2004 01:57 AM


All times are GMT +1. The time now is 04:59 AM.


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