Chart Styles

     

  • Each and every chart consists of 48 styles
  •  

  • This program enunciates how to create chart for each and every style
  •  

     

     

    Sub Chart_Styles()
    'Created object for sheet2
    Dim sh2 As Worksheet
    Set sh2 = ThisWorkbook.Sheets("sheet2")
    'www.Tricks12345.com
    Dim j As Integer
    j = 1
    'New workbook will open with only one worksheet
    Application.SheetsInNewWorkbook = j
    Dim wkb As Workbook
    Set wkb = Workbooks.Add
    'Charts having 48 styles for each and every type
    Dim i As Integer
    For i = 1 To 48
    Dim ch As Chart
    'create chart in new workbook
    Set ch = wkb.Charts.Add(after:=wkb.Sheets(Sheets.Count))
    With ch
    .ChartType = xlLine
    .Name = "Style" & i
    .ChartStyle = i
    .SetSourceData sh2.Range("A1:B10"), PlotBy:=xlColumns
    .HasLegend = True
    .Legend.Position = xlLegendPositionTop
    .HasDataTable = True
    .ApplyDataLabels xlDataLabelsShowValue
    End With
    Next
    'to restore the number of sheets as 3 when opened new workbook
    Application.SheetsInNewWorkbook = 3
    End Sub

     

    Download The Workbook