Charts

programmatically update a chart title

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
 
    ' update the chart title
    Dim currAvg As Integer
    currAvg = Application.WorksheetFunction.Floor(Worksheets("Data").Range("G21").Value, 1)
 
    With Chart1
        .HasTitle = True
 
        ' vbNewLine is a line break, appropriate for the current platform
        .ChartTitle.Text = "Tri-City Bowl - Pinbreakers League" _
            & vbNewLine _
            & "Bill Hartung" _
            & vbNewLine _
            & "Average: " _
            & currAvg
    End With
 
End Sub