Working with a Chart Axis : Chart Format « Excel « VBA / Excel / Access / Word






Working with a Chart Axis

 
Sub chartAxis()
    Dim myChartObject As ChartObject
    Set myChartObject = ActiveSheet.ChartObjects.Add(Left:=200, Top:=200, _
        Width:=400, Height:=300)
    
    myChartObject.Chart.SetSourceData Source:= _
        ActiveWorkbook.Sheets("Chart Data").Range("A1:E5")
    
    myChartObject.SeriesCollection.Add Source:=ActiveSheet.Range("C4:K4"), Rowcol:=xlRows
    myChartObject.SeriesCollection.NewSeries
    myChartObject.HasTitle = True
    
    With myChartObject.Axes(Type:=xlCategory, AxisGroup:=xlPrimary)
        .HasTitle = True
        .AxisTitle.Text = "Years"
        .AxisTitle.Font.Name = "Times New Roman"
        .AxisTitle.Font.Size = 12
        .HasMajorGridlines = True
        .HasMinorGridlines = False
    End With
End Sub

 








Related examples in the same category

1.Manipulating Charts
2.Adds major gridlines, title, and x-axis labels to an embedded chart
3.Loop through each series in chart and alter marker colors
4.Add Chart Sheet
5.Background and Foreground color
6.Formatting a Basic Chart
7.Format Axis, Title font size and color
8.Set Axes gridline and its border color
9.Set PlotArea LineStyle, border color, width and height
10.Looping through the ChartObjects collection: changes the chart type of every embedded chart on the active sheet.
11.works on all the chart sheets in the active workbook
12.Modifying chart properties: changes the Legend font for all charts on the active sheet.
13.Applying chart formatting
14.Changing a Chart Title Using VBA
15.To fill the bars of a data series with a picture
16.sets up a two-color gradient using two theme colors:
17.formats the trendline for the first series in a chart:
18.formatting a border
19.adds a line around the title and adds a glow around that line:
20.adds a light blue shadow to the box surrounding a legend:
21.proper syntax for SoftEdge:
22.Format Soft Edges With Loop
23.To apply one of the 3-D rotation presets to a chart element: use the SetPresetCamera method
24.Changing the Bevel and 3-D Format
25.defines a Chart object variable and a ChartGroup object variable and then stops:
26.creates the chart with absolute reference and format it