Results 1 to 10 of 10

Deactivate chart created with VBA

Threaded View

  1. #3
    Registered User
    Join Date
    06-17-2010
    Location
    Texas
    MS-Off Ver
    Excel 2000, Excel 2003, Excel 2007
    Posts
    4

    Re: Deactivate chart created with VBA

    I was able to assign the action without selecting the chart, however I do have to have the chart active in order to change the series properties. After which the chart does not deactivate, unless I step through the code line by line.

    Updated code:

    Sub FormatChart_Coverage(strChart As String)
    
    Dim srs As series
    
        ThisWorkbook.Sheets("Report").ChartObjects(strChart).Activate
        
            ActiveChart.SetElement (msoElementLegendNone) ''Hide the legend
            ActiveChart.SetElement (msoElementDataTableWithLegendKeys) ''Show the data table
        
        For Each srs In ActiveChart.SeriesCollection
        
            If srs.Name = "Total" Then
                srs.AxisGroup = 2
                srs.Select
                With Selection.Border
                    .Weight = xlThin
                    .LineStyle = xlNone
                End With
                Selection.Interior.ColorIndex = xlNone
    
            ElseIf srs.Name = "YTD Goal" Then
                srs.ChartType = xlLineMarkers
                srs.Select
                With Selection
                    .MarkerStyle = -4115
                    .MarkerSize = 13
                    .MarkerBackgroundColorIndex = 3
                    .MarkerForegroundColorIndex = 3
                End With
                With Selection.Border
                    .LineStyle = xlNone
                End With
            End If
        Next
              
        ActiveChart.DataTable.Font.Size = 8
        
        ActiveChart.Axes(xlValue, xlSecondary).MajorTickMark = xlNone
        ActiveChart.Axes(xlValue, xlSecondary).TickLabelPosition = xlNone
    
        ThisWorkbook.Sheets("Report").ChartObjects(strChart).OnAction = "'" & ThisWorkbook.Name & "'!Drill_CoverageForm"
             
        ThisWorkbook.Sheets("Report").Activate
        ActiveSheet.Range("A1").Select
    
    End Sub
    Last edited by kcaprik; 06-18-2010 at 09:33 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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