Set Lengend position and ChartArea Interior Color : Chart Lengend « 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 Lengend 
Set Lengend position and ChartArea Interior Color
 
Sub FormattingCharts()
    Dim myChart As Chart
    Dim ws As Worksheet
    Dim ax As Axis

    Set ws = ThisWorkbook.Worksheets("Sheet1")
    Set myChart = GetChartByCaption(ws, "GDP")

    If Not myChart Is Nothing Then
        myChart.ChartArea.Interior.Color = vbWhite
        myChart.Legend.Position = xlLegendPositionBottom
    End If

    Set ax = Nothing
    Set myChart = Nothing
    Set ws = Nothing
End Sub
Function GetChartByCaption(ws As Worksheet, sCaption As StringAs Chart
    Dim myChart As ChartObject
    Dim myChart As Chart
    Dim sTitle As String

    Set myChart = Nothing
    For Each myChart In ws.ChartObjects
        If myChart.Chart.HasTitle Then
            sTitle = myChart.Chart.ChartTitle.Caption
            If StrComp(sTitle, sCaption, vbTextCompareThen
                Set myChart = myChart.Chart
                Exit For
            End If
        End If
    Next
    Set GetChartByCaption = myChart
    Set myChart = Nothing
    Set myChart = Nothing
End Function

 
Related examples in the same category
1. Adding a Legend to the Chart
w___ww__._j__av__a__2s.__c___om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.