Showing posts with label Add and Remove fill colors from chart Using VBA. Show all posts
Showing posts with label Add and Remove fill colors from chart Using VBA. Show all posts

Saturday, January 19, 2013

Add and Remove fill colors from chart Using VBA

If you want to add or remove fill colors from chart.Try this macro - 








Macro to add fill color 

Sub add_fill_colors()
    Dim cht As Chart
    ' change chart name here
    Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
    'add fill color to chart area
    cht.ChartArea.Interior.Color = RGB(205, 104, 137)
    ' add fill color to Plot Area
    cht.PlotArea.Interior.Color = RGB(205, 193, 197)
End Sub


Macro to remove fill color

Sub remove_fill_colors()
    Dim cht As Chart
    ' change chart name here
    Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
    'Remove fill color from chart area
    cht.ChartArea.Fill.Visible = False
    'remove fill color from Plot Area
    cht.PlotArea.Fill.Visible = False
End Sub

Import data from SQL

Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...