Saturday, January 19, 2013

Macro to add Axis Titles

If you want to add or format  axis titles. Try this code




Sub add_axis_titles()
    Dim cht As Chart
    ' change chart name here
    Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
        
    With cht.Axes(xlCategory, xlPrimary)
    .HasTitle = True
    .AxisTitle.Text = "Reps"
    .AxisTitle.Font.Name = "Arial"
    .AxisTitle.Font.Size = 8
    .AxisTitle.Font.Color = RGB(255, 10, 35)
    End With
    
    With cht.Axes(xlValue, xlPrimary)
    .HasTitle = True
    .AxisTitle.Text = "Ranks"
    .AxisTitle.Font.Name = "Arial"
    .AxisTitle.Font.Size = 8
    .AxisTitle.Font.Color = RGB(0, 0, 128)
    End With
   
End Sub

No comments:

Post a Comment

Import data from SQL

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