Showing posts with label Macro to add gridlines in chart. Show all posts
Showing posts with label Macro to add gridlines in chart. Show all posts

Saturday, January 19, 2013

Macro to add gridlines in chart

If you want to add gridlines in chart . Try this macro






Sub add_Gridlines()
    Dim cht As Chart
    ' change chart name here
    Set cht = Sheets("Sheet1").ChartObjects("Chart 3").Chart
        
    With cht.Axes(xlCategory, xlPrimary)
    .HasMajorGridlines = True
    .MajorGridlines.Border.Color = RGB(186, 12, 255)
    .MajorGridlines.Border.LineStyle = xlContinuous
    .MajorGridlines.Border.Weight = xlThin
    .HasMinorGridlines = False
    End With
    
    With cht.Axes(xlValue, xlPrimary)
    .HasMajorGridlines = False
    .HasMinorGridlines = True
    .MinorGridlines.Border.Color = RGB(186, 12, 10)
    .MinorGridlines.Border.LineStyle = xlDashDot
    .MinorGridlines.Border.Weight = xlThin
    End With
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...