Consulting

Results 1 to 5 of 5

Thread: delete all sheets and charts except "Input"

  1. #1
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location

    delete all sheets and charts except "Input"

    Sub delete()
    Dim ws As Worksheet
    Application.DisplayAlerts = False
    For Each ws In Worksheets
    If ws.Name <> "Input" Then ws.delete
    Next
    Application.DisplayAlerts = True
    End Sub
    the above vba delete all sheets except "Input" but not the charts. I want all charts to be deleted also.
    Attached Images Attached Images

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Sub delete()
        Dim ws 'no As Worksheet
        Application.DisplayAlerts = False
        For Each ws In Sheets 'not WorkSheets
            If ws.Name <> "Input" Then ws.delete
        Next
        Application.DisplayAlerts = True
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    after Excel file is closed and re-open, all the sheets were deleted except "Input" and the charts and I need to apply macro "delete" again to
    delete the charts

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Quote Originally Posted by asdzxc View Post
    after Excel file is closed and re-open, all the sheets were deleted except "Input" and the charts and I need to apply macro "delete" again to
    delete the charts
    What?!?
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    VBAX Contributor
    Joined
    Apr 2012
    Posts
    107
    Location
    SOLVED

Posting Permissions

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