Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Chapel Hill, North Carolina, USA
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Identify chart name via VBA (97/2000)

    I have a spreadsheet which creates charts via VBA on a worksheet. I would like to delete any existing (older) charts on the worksheet before I begin, but can't figure out the Excel syntax in VBA to list/review all the charts/obejcts on a worksheet to identify the chart so I can delete it.

    Is this easy to do? (I'm sure it is once you know how!)

    Thanks!

    Larry

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Identify chart name via VBA (97/2000)

    For embedded charts use the chartobjects:
    "activesheet.chartobjects(1).name" is the name of chartobject 1 embedded on the activesheet

    For charts on their own sheets
    "Charts(1).name" will give you the name of the first chart
    Charts(1).delete
    or if you know the name:
    Charts("Sheetname").delete

    will delete the chart sheet

    Steve

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Identify chart name via VBA (97/2000)

    To delete all of the charts on Sheet1, you can use:

    <pre> Worksheets("Sheet1").ChartObjects.Delete
    </pre>

    Legare Coleman

Posting Permissions

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