Consulting

Results 1 to 3 of 3

Thread: naming charts

  1. #1

    naming charts

    Hi,

    I used the following code to create a chart:

    With shtMain.ChartObjects.Add _
    (Left:=20, Width:=430, Top:=170, Height:=225)
    .Chart.SetSourceData source:=Sheets("Results").Range("$d$2:$e$" & rowCount)
    .Chart.ChartType = xlColumn
    End With

    and it works fine for creating the chart but on the right hand side of the chart is "Series 1".
    I can't figure out how to get rid of that or to get a title to display on my chart.


    Thanks
    Don

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    try:[vba]With shtMain.ChartObjects.Add _
    (Left:=20, Width:=430, Top:=170, Height:=225)
    .Chart.SetSourceData Source:=Sheets("Results").Range("$d$2:$e$" & RowCount)
    .Chart.ChartType = xlColumn

    .Chart.Legend.Delete
    .Chart.SetElement (msoElementChartTitleCenteredOverlay)
    .Chart.ChartTitle.Text = "My Title"

    ' With .Chart.ChartTitle.Format.TextFrame2.TextRange
    ' .Characters.Text = "My Title"
    ' With .Characters(1, 8)
    ' With .ParagraphFormat
    ' .TextDirection = msoTextDirectionLeftToRight
    ' .Alignment = msoAlignCenter
    ' End With
    ' With .Font
    ' .BaselineOffset = 0
    ' .Bold = msoTrue
    ' .NameComplexScript = "+mn-cs"
    ' .NameFarEast = "+mn-ea"
    ' .Fill.Visible = msoTrue
    ' .Fill.ForeColor.RGB = RGB(0, 0, 0)
    ' .Fill.Transparency = 0
    ' .Fill.Solid
    ' .Size = 18
    ' .Italic = msoFalse
    ' .Kerning = 12
    ' .Name = "+mn-lt"
    ' .UnderlineStyle = msoNoUnderline
    ' .Strike = msoNoStrike
    ' End With
    ' End With
    ' End With
    End With
    [/vba] I recorded a macro, tweaked it a bit. The red lines are what you asked for. The commented-out lines where also recorded but you may find they're not needed.
    I was using Excel 2010.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    thanks p45cal. exactly what I was looking for!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •