+ Reply to Thread
Results 1 to 6 of 6

Clear diagrams does not work

  1. #1
    Registered User
    Join Date
    12-14-2011
    Location
    vienna
    MS-Off Ver
    Excel 2007
    Posts
    3

    Red face Clear diagrams does not work

    In Excel 2003 this code worked for clearing all diagrams in worksheet:

    Worksheets(ws_data).ChartObjects.Delete

    Now in Excel 2007 it only works, if there is at least one diagram. When starting it does not work (first time). Returns runtime error 1004.
    Last edited by whohe; 12-14-2011 at 08:22 AM.

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Clear diagrams does not work

    try this
    Please Login or Register  to view this content.
    Last edited by tom1977; 12-14-2011 at 07:51 AM.
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Registered User
    Join Date
    12-14-2011
    Location
    vienna
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Clear diagrams does not work

    Thanks for the reply.
    It does not work - runtime error '9' (Index ausserhalb des gültigen Bereichs)

    this is the coding:
    Public Sub NeuesDiagramm()
    '
    ' NeuesDiagramm Makro
    Dim ref As String

    ' Alle alten Diagramme löschen
    Worksheets("ws_data").ChartObjects.Delete

  4. #4
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Clear diagrams does not work

    Sorry I do not speak German (I think)
    Could You please send attachment with Your excel file

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Clear diagrams does not work

    That implies your sheet is not called "ws_data". Based on your original code, you would want:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Registered User
    Join Date
    12-14-2011
    Location
    vienna
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Clear diagrams does not work

    Thank you for your help - it works now with a litte modification:
    If Worksheets(ws_data).ChartObjects.Count >= 1 Then
    Worksheets(ws_data).ChartObjects.Delete
    Else:

    End If

+ Reply to Thread

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