+ Reply to Thread
Results 1 to 6 of 6

ThisWorkbook code not hiding named sheets

  1. #1
    Registered User
    Join Date
    02-03-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    ThisWorkbook code not hiding named sheets

    Hi, I have a seemingly simple problem but I can't seem to get around it. Perhaps someone else could enlighten me. When the user closes the workbook, I would like all worksheets except Inputs, SummaryOutput and DetailedOutput to be hidden. My attempt at the code is below:
    Please Login or Register  to view this content.
    It's giving me a runtime error 1004- any ideas why? Any help would be greatly appreciated!

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: ThisWorkbook code not hiding named sheets

    Does this work in place of your For/Next loop

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: ThisWorkbook code not hiding named sheets

    On what line is the error? Are any sheets being hidden?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: ThisWorkbook code not hiding named sheets

    Another possible issue is that VBA is case sensitive by default so the string comparisons may not match the actual name of the worksheets - either convert to same case (upper/lower) to compare or include
    Please Login or Register  to view this content.
    in the General Declarations section of the module.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: ThisWorkbook code not hiding named sheets

    What it sounds like is its trying to hide all sheets. I believe one has to remain unhidden.

  6. #6
    Registered User
    Join Date
    02-03-2013
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: ThisWorkbook code not hiding named sheets

    Actually BigBas solved it! The For loop needed brackets as suggested- many thanks to all for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Hiding Sheets based on cell value, only hiding last sheet
    By mattblack2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2014, 03:21 PM
  2. How to get my code to target only sheets that are named in a specific ranges?
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2014, 09:13 AM
  3. [SOLVED] Uncheck Checkbox on ThisWorkbook > On All Sheets
    By cychua in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-23-2013, 11:49 AM
  4. Problem hiding columns of a sheet with code that is operative in other sheets
    By RagonichaFulva in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2011, 04:56 AM
  5. VBA code to search cell data in named sheets
    By Zimmerman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-03-2010, 11:46 AM

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