Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Trying to add a Pie Chart

Excel doesn't know what you mean by NewChart. Change NewChart to
OnTimeStatus or vice versa, and try again.

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

jmdaniel wrote:

Keeping running into "Run Time Error 424 Object Required" error on the following code, line 4:

Sub Chart()
Dim OnTimeStatus As Chart
Set OnTimeStatus = ThisWorkbook.Charts.Add()
NewChart.Name = "On Time Status"
NewChart.ChartType = x1PieExploded
NewChart.SetSourceData Source:=Worksheets("NI Supplier Delivery Performan").Range("P1:P300")

End Sub

And how would I get the chart to show up in the actual file the data is in, instead of showing up in the file the macro is in? I assume I replace ThisWorkbook above with the name of the file, but that didn't work, perhaps because of this other issue.

Thanks.






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Trying to add a Pie Chart

Check the chart type. Looks like you have x1pieexploded (x-one) instead
of xlpieexploded (x-elle). You should type them all caps or all
lowercase, and if it's spelled right, the case will change. Better yet,
let Intellisense give you the list, and select the one you want.

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

jmdaniel wrote:

Okay, now I get a Run Time 13 Error, Type Mismatch, on line 5.

Sub Chart()
Dim OnTimeStatus As Chart
Set OnTimeStatus = ThisWorkbook.Charts.Add()
OnTimeStatus.Name = "On Time Status"
OnTimeStatus.ChartType = x1PieExploded
OnTimeStatus.SetSourceData Source:=Worksheets("NI Supplier Delivery Performan").Range("P1:P300")

End Sub

The macro created a sheet in the file the macro is in, called "On Time Status", so it looks like the first 3 or 4 lines are working, but the help screen for this run time error isn't very helpful. Also, I am using this macro over and over, modifying another file, and actually want the chart to show up in the other file, not in the file the macro is in. I didn't find anything that tells me how to specify where the chart sheet shows up. I swear, I will be spending time with my new macro book this weekend, but I would like to get this knocked out today. Help!



"Jon Peltier" wrote:


Excel doesn't know what you mean by NewChart. Change NewChart to
OnTimeStatus or vice versa, and try again.

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

jmdaniel wrote:


Keeping running into "Run Time Error 424 Object Required" error on the following code, line 4:

Sub Chart()
Dim OnTimeStatus As Chart
Set OnTimeStatus = ThisWorkbook.Charts.Add()
NewChart.Name = "On Time Status"
NewChart.ChartType = x1PieExploded
NewChart.SetSourceData Source:=Worksheets("NI Supplier Delivery Performan").Range("P1:P300")

End Sub

And how would I get the chart to show up in the actual file the data is in, instead of showing up in the file the macro is in? I assume I replace ThisWorkbook above with the name of the file, but that didn't work, perhaps because of this other issue.

Thanks.








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Trying to add a Pie Chart

Your code doesn't specify which workbook contains the sheet with the
data, so Excel uses the specified worksheet in the active workbook. So
replace ThisWorkbook with ActiveWorkbook.

To specify a particular workbook for the chart and for the data range,
refer to it like this:

Sub Chart()
Dim OnTimeWorkbook as Workbook
Dim OnTimeStatus As Chart
Set OnTimeWorkbook = Workbooks("MyWorkbook.xls")
Set OnTimeStatus = OnTimeWorkbook.Charts.Add()
OnTimeStatus.Name = "On Time Status"
OnTimeStatus.ChartType = x1PieExploded
OnTimeStatus.SetSourceData Source:=OnTimeWorkbook.Worksheets("NI
Supplier Delivery Performan").Range("P1:P300")
End Sub

The data and the chart can be in two different workbooks.

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


jmdaniel wrote:

Thanks, Jon. Any idea on my other question, which is to have the chart show up in the file the data is in, not in the file that contains the macro?

Jeff

"Jon Peltier" wrote:


Check the chart type. Looks like you have x1pieexploded (x-one) instead
of xlpieexploded (x-elle). You should type them all caps or all
lowercase, and if it's spelled right, the case will change. Better yet,
let Intellisense give you the list, and select the one you want.

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

jmdaniel wrote:


Okay, now I get a Run Time 13 Error, Type Mismatch, on line 5.

Sub Chart()
Dim OnTimeStatus As Chart
Set OnTimeStatus = ThisWorkbook.Charts.Add()
OnTimeStatus.Name = "On Time Status"
OnTimeStatus.ChartType = x1PieExploded
OnTimeStatus.SetSourceData Source:=Worksheets("NI Supplier Delivery Performan").Range("P1:P300")

End Sub

The macro created a sheet in the file the macro is in, called "On Time Status", so it looks like the first 3 or 4 lines are working, but the help screen for this run time error isn't very helpful. Also, I am using this macro over and over, modifying another file, and actually want the chart to show up in the other file, not in the file the macro is in. I didn't find anything that tells me how to specify where the chart sheet shows up. I swear, I will be spending time with my new macro book this weekend, but I would like to get this knocked out today. Help!



"Jon Peltier" wrote:



Excel doesn't know what you mean by NewChart. Change NewChart to
OnTimeStatus or vice versa, and try again.

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

jmdaniel wrote:



Keeping running into "Run Time Error 424 Object Required" error on the following code, line 4:

Sub Chart()
Dim OnTimeStatus As Chart
Set OnTimeStatus = ThisWorkbook.Charts.Add()
NewChart.Name = "On Time Status"
NewChart.ChartType = x1PieExploded
NewChart.SetSourceData Source:=Worksheets("NI Supplier Delivery Performan").Range("P1:P300")

End Sub

And how would I get the chart to show up in the actual file the data is in, instead of showing up in the file the macro is in? I assume I replace ThisWorkbook above with the name of the file, but that didn't work, perhaps because of this other issue.

Thanks.









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
Dynamic chart- curve dropping to zero ( chart type- Line) vmohan1978 Charts and Charting in Excel 0 February 1st 10 09:11 AM
how to remove dotted line with words chart area from around chart desof Charts and Charting in Excel 2 May 13th 09 10:18 PM
Excel 2003 is missing Built-In Custom Chart Types in Chart Wizard Julius Charts and Charting in Excel 2 March 6th 09 04:43 PM
Excel 2003 is missing Built-In Custom Chart Types in Chart Wizard Julius Setting up and Configuration of Excel 1 March 6th 09 01:57 AM
Excel 2003: How to nudge a chart element or shape on a chart? Ted M H Charts and Charting in Excel 5 June 30th 08 07:08 PM


All times are GMT +1. The time now is 06:11 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"