Automatically generating a chart without user interaction : Chart « Excel « VBA / Excel / Access / Word

VBA / Excel / Access / Word
1. Access
2. Application
3. Data Type
4. Data Type Functions
5. Date Functions
6. Excel
7. File Path
8. Forms
9. Language Basics
10. Math Functions
11. Outlook
12. PowerPoint
13. String Functions
14. Windows API
15. Word
16. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VBA / Excel / Access / Word » Excel » Chart 
Automatically generating a chart without user interaction
 
Sub CreateChart(r)
    Dim TempChart As Chart
    Application.ScreenUpdating = False
    
    Set CatTitles = ActiveSheet.range("A2:F2")
    Set SrcRange = ActiveSheet.range(Cells(r, 1), Cells(r, 6))
    Set SourceData = Union(CatTitles, SrcRange)
    
    Set TempChart = Charts.Add
    With TempChart
        .ChartType = xlColumnClustered
        .SetSourceData Source:=SourceData, PlotBy:=xlRows
        .HasLegend = False
        .ApplyDataLabels Type:=xlDataLabelsShowValue, _
         LegendKey:=False
        .ChartTitle.Font.Size = 14
        .ChartTitle.Font.Bold = True
        .Axes(xlValue).MaximumScale = 0.6
        .Axes(xlCategory).TickLabels.Font.Size = 10
        .Axes(xlCategory).TickLabels.Orientation = _
         xlHorizontal
        .Location Where:=xlLocationAsObject, name:="Sheet1"
    End With
    With ActiveSheet.ChartObjects(1)
        .Width = 300
        .Height = 150
        .Visible = False
    End With
End Sub

 
Related examples in the same category
1. Creating a New Chart Using the ChartWizard Method
2. Creating a Chart Using the Chart Object
3. Creating a Chart
4. Creating a Chart on an Existing Worksheet
5. Specifying the Source Data for the Chart by using the SetSourceData method of the Chart object
6. Specifying the Chart Type
7. Adding a New Series to the chart identified by the object variable myChart, drawing the data from the range C4:K4 on the active worksheet in the active workbook, using rows:
8. Extending an Existing Series in the chart identified by the object variable myChart using the data in the cells P3:P8 on the worksheet named Chart Data:
9. Creating a New Series, use the NewSeries method with the SeriesCollection collection.
10. Creating Charts
11. Creating an Embedded Chart
12. Add Chart
13. Select a chart object
14. Get Chart sheet
15. Reference Char object from ActiveSheet
16. Get Embedded Charts
17. Inserts a chart before each sheet
18. Inserts a chart before each sheet 2
19. Determining a chart's source data
20. Get Chart SeriesCollection value
21. Retrieving data point labels from field names in the worksheet
22. Show chart
23. Producing an Excel worksheet on a Word 2000 document
24. Insert two chart sheets after the last worksheet in the active workbook. The chart sheets receive default names, such as Chart1 and Chart2:
25. Use For Each to loop through all chart objects
26. Activates the ChartObject named Chart 1
27. Modifying the chart type
28. To ensure that a chart is selected, you can add a statement to determine if a chart is active.
29. In most cases you can avoid using the worksheet Index property
30. Insert chart sheets after each worksheet
31. Adding a Chart Sheet Using VBA Code
32. convert an existing chart to use arrays instead of cell references and make it independent of the original data
33. add the data labels using the following code:
34. Referencing Charts and Chart Objects in VBA Code
35. Specify Exact Location
w_w__w__.___ja_v___a__2s___._c___o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.