+ Reply to Thread
Results 1 to 3 of 3

Looping through chart worksheets

  1. #1
    Registered User
    Join Date
    04-13-2005
    Posts
    11

    Looping through chart worksheets

    I am trying to use a loop to delete any worksheet that ends in 'Chart' using the following code:

    Dim ws As Worksheet
    For Each ws In Worksheets
    If Right(ws.Name, 5) = "Chart" Then ws.Delete
    Next

    However, this code does not appear to pick up worksheets created with through the chart wizard.
    I have stepped through the code and can see that it skips the worksheet with a chart.
    Are chart worksheets different in some way to normal worksheets?
    Please help!

  2. #2
    Dave Peterson
    Guest

    Re: Looping through chart worksheets

    There are different types of sheets that can be in a workbook.

    Worksheets
    Chart Sheets
    Macro Sheets
    International Macro Sheets
    Dialog sheets

    If you want to loop through all the sheets:

    dim ws as object
    for each ws in Sheets
    ....


    stuartmarsh wrote:
    >
    > I am trying to use a loop to delete any worksheet that ends in 'Chart'
    > using the following code:
    >
    > Dim ws As Worksheet
    > For Each ws In Worksheets
    > If Right(ws.Name, 5) = "Chart" Then ws.Delete
    > Next
    >
    > However, this code does not appear to pick up worksheets created with
    > through the chart wizard.
    > I have stepped through the code and can see that it skips the worksheet
    > with a chart.
    > Are chart worksheets different in some way to normal worksheets?
    > Please help!
    >
    > --
    > stuartmarsh
    > ------------------------------------------------------------------------
    > stuartmarsh's Profile: http://www.excelforum.com/member.php...o&userid=22142
    > View this thread: http://www.excelforum.com/showthread...hreadid=571344


    --

    Dave Peterson

  3. #3
    Registered User
    Join Date
    04-13-2005
    Posts
    11
    Thanks that sorted it.

+ 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