+ Reply to Thread
Results 1 to 3 of 3

Looping through a workbook with sheets and charts

  1. #1
    Registered User
    Join Date
    11-18-2008
    Location
    Richmond, VA
    Posts
    18

    Looping through a workbook with sheets and charts

    So I'm trying to go through a workbook and, based on some user inputs, hide certain sheets and charts (these charts are their own tab, i.e. a chart object). Here's a sample code I wrote for a dummy workbook I have. Unfortunately it doesn't work, I think because the loops are nested. However if I can figure out how to fix this code I can easily adapt it to my other real problem. Please let me know what I'm doing wrong and/or how I can solve this issue.

    Please Login or Register  to view this content.
    Is there a way to scan through the workbook in one loop (sheets and charts together)? I think that's what I'm missing here. Thanks!
    Last edited by Masact; 06-30-2009 at 05:59 PM.

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Looping through a workbook with sheets and charts

    I think what you are looking for here is the use of "Sheets" instead of "Worksheets". I recently came across it when working with charts too.

    Looping through "Sheets" includes all the worksheets and all the chart-sheets, whereas looping through "Worksheets" only includes the worksheets

    Something like this I think:

    Please Login or Register  to view this content.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Registered User
    Join Date
    11-18-2008
    Location
    Richmond, VA
    Posts
    18

    Re: Looping through a workbook with sheets and charts

    Thanks, yeah I actually stumbled across that myself earlier when I was trying to fix it. Thanks for your help!

    Out of curiosity, how does the Variant property work?

+ 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