+ Reply to Thread
Results 1 to 8 of 8

Delete chartobject without deleting ALL charts on sheet

  1. #1
    Registered User
    Join Date
    02-16-2012
    Location
    sa
    MS-Off Ver
    Excel 2007
    Posts
    80

    Delete chartobject without deleting ALL charts on sheet

    Good day I have created various charts using the the following code and place them on to sheet 2. However, I want to delete 1 chart from the sheet and not all of them. How do I delete a specific chart?


    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645
    With it's name or index perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-05-2013
    Location
    Portsmouth, UK
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Delete chartobject without deleting ALL charts on sheet

    of course you then need to know the index of the chart you want to delete.

    The easiest way is to set the name of the chart as you create it, then you can refernce it by name if you need to edit it later

  4. #4
    Registered User
    Join Date
    02-16-2012
    Location
    sa
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Delete chartobject without deleting ALL charts on sheet

    Hi I have tried to do this but it doesnt seem to work. I have tried this:

    Please Login or Register  to view this content.
    and then tried to delete it with the following code

    Please Login or Register  to view this content.
    But it doesnt seem to work

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Delete chartobject without deleting ALL charts on sheet

    How doesn't it work?

    Do you get an error if you remove the On Error Resume Next?

  6. #6
    Registered User
    Join Date
    02-16-2012
    Location
    sa
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Delete chartobject without deleting ALL charts on sheet

    Yes it does give me an error

    I put a msgbox after

    [Code]
    .Chart.Name = "SAIDI CNC"
    MsgBox .Chart.Name
    [\Code]

    and it returns Sheet2 Chart 2289 in the msgbox and not SAIDI CNC, thus something must be wrong in the naming??

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Delete chartobject without deleting ALL charts on sheet

    Any particular error?

  8. #8
    Registered User
    Join Date
    02-16-2012
    Location
    sa
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Delete chartobject without deleting ALL charts on sheet

    I used the following code and it seems to have worked.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Loop to Delete worksheets stops after deleting one sheet...
    By booDaddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2014, 05:12 PM
  2. Changing code from deleting rows to cut/paste rows into another sheet and delete blank row
    By kmarshall6576 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-18-2013, 01:54 AM
  3. Charts - delete when I delete surrounding rows
    By Romanian37 in forum Excel General
    Replies: 2
    Last Post: 11-22-2010, 06:10 AM
  4. Deleting all charts
    By pakiyabhai in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 04-28-2010, 03:59 AM
  5. Deleting All charts using VB
    By BrownTing in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2006, 11:05 AM

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