Chart with Log axis and Fill Chart Area

     

    Download The Workbook

    Sub Line_chart_withLog_Axis()
    Application.DisplayAlerts = False

    ActiveWindow.DisplayGridlines = False
    On Error Resume Next

    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets.Add(after:=ThisWorkbook.Worksheets(Sheets.Count), Count:=1)
    sh.Activate
    sh.Name = "Chart with Log Axis"
    ActiveWindow.DisplayGridlines = False

    Dim Datasheet As Worksheet
    Set Datasheet = ThisWorkbook.Sheets("Data Sheet")
    Datasheet.Range("B4:C9").Copy sh.Range("B4")

    Sheets("Log Axis").Delete
    Dim ch As ChartObject

    With sh.Range("E4:L17")
    Set ch = sh.ChartObjects.Add( _
    Left:=.Left, _
    Top:=.Top, _
    Width:=.Width, _
    Height:=.Height)
    End With
    With ch.Chart
    .ChartType = xlLine
    .SeriesCollection.NewSeries
    .SeriesCollection(1).Name = "Sales Data"
    .SeriesCollection(1).Values = sh.Range("C5:C9")
    .SeriesCollection(1).XValues = sh.Range("B5:B9")
    .SeriesCollection(1).ApplyDataLabels
    .Axes(xlValue).ScaleType = xlLogarithmic
    .SeriesCollection(1).Interior.Color = RGB(255, 0, 0)
    .HasLegend = True
    .Legend.Position = xlLegendPositionTop
    End With
    sh.Range("B2").Value = "Line chart with Log axis"
    With sh.Range("B2:K2")
    .HorizontalAlignment = xlCenterAcrossSelection
    .Font.Size = 25
    .Font.Name = "high tower text"
    .Interior.ColorIndex = 3
    End With
    Application.DisplayAlerts = True
    End Sub

     

     

     

     

     

     

     

    Sub Fill_ChartArea()
    On Error Resume Next
    'Define variable for worksheet
    Dim sh As Worksheet
    Set sh = ThisWorkbook.Sheets.Add(after:=ThisWorkbook.Worksheets(Sheets.Count), Count:=1)
    sh.Activate
    sh.Name = "Fill Chart Area"
    ActiveWindow.DisplayGridlines = False

    'Copy the data from Datasheet to newly created sheet
    Dim Datasheet As Worksheet
    Set Datasheet = ThisWorkbook.Sheets("Data Sheet")
    Datasheet.Range("B4:C9").Copy sh.Range("B4")


    Dim ch As ChartObject
    With sh.Range("F3:M17")
    Set ch = sh.ChartObjects.Add( _
    Left:=.Left, _
    Top:=.Top, _
    Width:=.Width, _
    Height:=.Height)
    End With
    With ch.Chart
    .ChartType = xlColumnClustered
    .SetSourceData sh.Range("B4:C9"), PlotBy:=xlColumns
    .HasTitle = True
    .ChartTitle.Text = "Fill Chart Area"
    .HasLegend = True
    .Legend.Position = xlLegendPositionTop
    .ChartArea.Format.Fill.ForeColor.RGB = RGB(225, 0, 0)
    .ChartArea.Interior.ColorIndex = 18
    .ChartArea.Border.ColorIndex = 5
    End With
    End Sub