Forum Statistics
- Forum Members:
- Total Threads:
- Total Posts: 5
There are 1 users currently browsing forums.
|
 |

06-21-2009, 11:15 PM
|
|
Registered User
|
|
Join Date: 16 Jun 2009
Location: san jose ca
MS Office Version:Excel 2007
Posts: 4
|
|
Create Chart Macro from Report - Question
Please Register to Remove these Ads
Hi, I am looking for a suggestion.
The attach file has tab Report with alot of data and charttest.
1. Can all the 6 charts be created by one macro?
2. Use a button to update?
I tried to test my 2 pie charts using the code from the website: 
The bottom ActiveCharts has errors.
http://pubs.logicalexpressions.com/P...cle.asp?ID=390
Code:
Sub MyPie()
' Select the cell in the upper-left corner of the chart.
Range("ae9").Select
' Select the current range of data. This line of code assumes that
' the current region of cells is contiguous - without empty rows
' or columns.
Selection.CurrentRegion.Select
' Assign the address of the selected range of cells to a variable.
myrange = Selection.Address
' Assign the name of the active sheet to a variable. This line is
' used in order to allow a chart to be created on a separate chart
' sheet.
mysheetname = ActiveSheet.Name
' Add a chart to the active sheet.
ActiveSheet.ChartObjects.Add(125.25, 60, 301.5, 155.25).Select
' To create a chart on a separate chart sheet, remark out the
' previous line, and substitute the next line for the one above.
' Charts.Add
Application.CutCopyMode = False
' This line can best be written by recording a macro, and
' modifying the code generated by the Microsoft Excel Macro
' recorder.
ActiveChart.ChartWizard _
Source:=Sheets(mysheetname).Range(myrange), _
Gallery:=xlPie, Format:=8, PlotBy:=xlRows, _
CategoryLabels:=1, SeriesLabels:=1, HasLegend:=0, _
Title:="", CategoryTitle:="", _
ValueTitle:="", ExtraTitle:=""
ActiveChart.SeriesCollection(2).HasDataLabels = True
End Sub
Thanks,
Last edited by dontuch_dg; 07-01-2009 at 02:50 PM.
Reason: I did not add attachment
|

06-22-2009, 04:09 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
|
|
|
Re: Create Chart Macro from Report - Question
Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
|

06-22-2009, 04:17 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
|
|
|
Re: Create Chart Macro from Report - Question
These changes wil at least get the code to run
Code:
Sub MyPie()
' Select the cell in the upper-left corner of the chart.
Range("ae9").Select
' Select the current range of data. This line of code assumes that
' the current region of cells is contiguous - without empty rows
' or columns.
Selection.CurrentRegion.Select
' Assign the address of the selected range of cells to a variable.
myrange = Selection.Address
' Assign the name of the active sheet to a variable. This line is
' used in order to allow a chart to be created on a separate chart
' sheet.
mysheetname = ActiveSheet.Name
' Add a chart to the active sheet.
ActiveSheet.ChartObjects.Add(125.25, 60, 301.5, 155.25).Select
' To create a chart on a separate chart sheet, remark out the
' previous line, and substitute the next line for the one above.
' Charts.Add
Application.CutCopyMode = False
' This line can best be written by recording a macro, and
' modifying the code generated by the Microsoft Excel Macro
' recorder.
ActiveChart.ChartWizard _
Source:=Sheets(mysheetname).Range(myrange), _
Gallery:=xlPie, Format:=8, PlotBy:=xlColumns, _
CategoryLabels:=1, SeriesLabels:=1, HasLegend:=0, _
Title:=""
' ActiveChart.SeriesCollection(2).HasDataLabels = True
End Sub
|

06-30-2009, 04:54 PM
|
|
Registered User
|
|
Join Date: 16 Jun 2009
Location: san jose ca
MS Office Version:Excel 2007
Posts: 4
|
|
|
Re: Create Chart Macro from Report - Question
Thanks Andy, I tried to remove the legend and include those labels into the pie? I am new to this site; How do I insert "solved" to threads?
|

07-01-2009, 04:12 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
|
|
|
Re: Create Chart Macro from Report - Question
In the bar above the posts is a menu item How To...? with link to mark a thread solved.
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|