Results 1 to 14 of 14

VBA Assign Chart Series Name

Threaded View

  1. #1
    Registered User
    Join Date
    03-10-2024
    Location
    Berlin
    MS-Off Ver
    mac2016
    Posts
    94

    VBA Assign Chart Series Name

    How do you insert the Chart Series Name by code?

    Manually, this can be accomplished via "Select Data Source": select "Name", select cell(s), done.

    I'd like the Series Name to be highlighted with the red frame, when the chart is selected.
    Just like the Categories and Values are highlighted in purple and blue.

    Tried this, doesn't work:

    objChart.Chart.Name = Range("B1")
    This is the create chart code:
    Sub Create_Column_Chart()
        Dim objChart As ChartObject
        Dim myChtRange As Range
        Dim myDataRange As Range
        With ActiveSheet
            Set myChtRange = .Range("B7:C12")
            Set myDataRange = .Range("B2:C3")
            Set objChart = .ChartObjects.Add( _
                Left:=myChtRange.Left, Top:=myChtRange.Top, _
                Width:=myChtRange.Width, Height:=myChtRange.Height)
            With objChart.Chart
                .ChartArea.AutoScaleFont = False
                .ChartType = xlColumnClustered
                .SetSourceData Source:=myDataRange
                .SeriesCollection(1).Name = Range("B1")
                .SeriesNameLevel = xlSeriesNameLevelCustom
    '            .Name = Range("B1") ' <<<<<<< causes "Run-time error '7': Out of memory"
                .HasLegend = False
                .HasTitle = False
                .ChartArea.RoundedCorners = False
                .ChartArea.Format.Line.Visible = True
                .ChartArea.Format.Line.Weight = 5
                .ChartArea.Format.Line.ForeColor.RGB = RGB(255, 217, 102)
                .SetElement (msoElementPrimaryValueGridLinesNone)
                ' X-Axis
                .HasAxis(xlCategory) = False
                ' Y-Axis
                .HasAxis(xlValue) = False
            End With
        End With
    End Sub
    Thank you!
    Last edited by briskie; 04-03-2024 at 12:50 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Matching 'Chart Series title' to equation driven cells to set the series line colour
    By mattydboom1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-15-2020, 09:36 AM
  2. Replies: 2
    Last Post: 02-19-2017, 07:52 PM
  3. Delete Pivto Chart Series when certain word/text is found in the Series Name
    By trizzo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-06-2016, 03:19 PM
  4. Apply format of a series to a similar series in a different chart
    By Skiffie in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-05-2013, 10:43 PM
  5. Chart front-to-back series display if series are different chart types
    By Exconomist in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-06-2012, 06:49 AM
  6. mixing column chart types for series and macro series?
    By riwiseuse in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-30-2010, 05:27 PM
  7. chart data series -- plot a table as a single series
    By hjc in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 09-20-2005, 01:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1