+ Reply to Thread
Results 1 to 4 of 4

VBA Needed to remove graphs

  1. #1
    Karoo News
    Guest

    VBA Needed to remove graphs

    Hi all I have in a workbook vba code that creates a graph when a sheet is
    activated. These happen on sheets 4 to 42. The reason I do this is to keep
    the file size small as it is used on Excel 97. The problem i have is trying
    to remove these graphs when the sheet deactivates due to the new sheet
    activation code working. Is there a simple quick code that can remove any
    graphs that are in pages 4 to 42 that I could put in say sheet activation
    before the new graph code!

    Hope this makes sense!

    Regards
    Neil




  2. #2
    Tom Ogilvy
    Guest

    Re: VBA Needed to remove graphs

    for each sh in Sheets
    if sh.Index > 3 then
    if sh.ChartObjects.Count > 0 then
    sh.ChartObjects.Delete
    end if
    end if
    Next

    --
    Regards,
    Tom Ogilvy


    "Karoo News" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all I have in a workbook vba code that creates a graph when a sheet is
    > activated. These happen on sheets 4 to 42. The reason I do this is to keep
    > the file size small as it is used on Excel 97. The problem i have is

    trying
    > to remove these graphs when the sheet deactivates due to the new sheet
    > activation code working. Is there a simple quick code that can remove any
    > graphs that are in pages 4 to 42 that I could put in say sheet activation
    > before the new graph code!
    >
    > Hope this makes sense!
    >
    > Regards
    > Neil
    >
    >
    >




  3. #3
    Peter T
    Guest

    Re: VBA Needed to remove graphs

    Hi Neil,

    Assuming you want to delete all charts on any deactivated sheet, try this in
    the ThisWorkbook module -

    Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
    Sh.ChartObjects.Delete
    End Sub

    Regards,
    Peter T

    "Karoo News" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all I have in a workbook vba code that creates a graph when a sheet is
    > activated. These happen on sheets 4 to 42. The reason I do this is to keep
    > the file size small as it is used on Excel 97. The problem i have is

    trying
    > to remove these graphs when the sheet deactivates due to the new sheet
    > activation code working. Is there a simple quick code that can remove any
    > graphs that are in pages 4 to 42 that I could put in say sheet activation
    > before the new graph code!
    >
    > Hope this makes sense!
    >
    > Regards
    > Neil
    >
    >
    >




  4. #4
    Rob van Gelder
    Guest

    Re: VBA Needed to remove graphs

    Check out my website for Shape Delete.
    That allows you a bit of control over which Shapes are removed and which
    remain.

    --
    Rob van Gelder - http://www.vangelder.co.nz/


    "Karoo News" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all I have in a workbook vba code that creates a graph when a sheet is
    > activated. These happen on sheets 4 to 42. The reason I do this is to keep
    > the file size small as it is used on Excel 97. The problem i have is
    > trying to remove these graphs when the sheet deactivates due to the new
    > sheet activation code working. Is there a simple quick code that can
    > remove any graphs that are in pages 4 to 42 that I could put in say sheet
    > activation before the new graph code!
    >
    > Hope this makes sense!
    >
    > Regards
    > Neil
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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