• Macro to list chart objects (Excel 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Macro to list chart objects (Excel 2000)

    Author
    Topic
    #423350

    To list them in a new worksheet in the active workbook:

    Sub Chartlist()
    Dim wks As Worksheet
    Dim lngS As Long, lngC As Long, lngX As Long

    Set wks = ActiveWorkbook.Worksheets.Add
    For lngS = 1 To ActiveWorkbook.Sheets.Count
    With ActiveWorkbook.Sheets(lngS)
    For lngC = 1 To .ChartObjects.Count
    lngX = lngX + 1
    wks.Cells(lngX, 1).Value = .Name & “; ” & .ChartObjects(lngC).Name
    Next lngC
    End With
    Next lngS
    wks.Columns(1).WrapText = False
    wks.Columns(1).EntireColumn.AutoFit
    Set wks = Nothing
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #968512

      Subject edited by HansV to aid in future searches

      Is there VBA code that can give me a list of chart objects represented in a tab? I have several excel tabs that have numerous charts on them. Over time, they have accumulated and the names are “chart 1, chart 6, etc…”. I am writing VBA print code to print groups of the charts with a button, but I would like a list of all the chart as they are named to reference, especially if I add more later and wonder which ones I already had.

      • #968574

        I don’t work much with charts or charts in VBA, but see if this gets you started:

        Sub Chartlist()
        Dim lngC As Long, lngS As Long
        Dim strL As String

        For lngS = 1 To ActiveWorkbook.Sheets.Count
        With ActiveWorkbook.Sheets(lngS)
        For lngC = 1 To .ChartObjects.Count
        strL = strL & .Name & “; ” & .ChartObjects(lngC).Name & vbLf
        Next lngC
        End With
        Next lngS
        MsgBox strL
        End Sub

    Viewing 0 reply threads
    Reply To: Macro to list chart objects (Excel 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: