+ Reply to Thread
Results 1 to 7 of 7

Unable to set the visible property of the worksheet class

  1. #1
    Registered User
    Join Date
    01-06-2009
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Unable to set the visible property of the worksheet class

    Hi All,

    I've been using the following code successfully for years. Today I would get the error 1004:Unable to set the visible property of the worksheet class. All my searches came up with someone not realizing they had protected the workbook. As you can see, the first thing I do before trying to set the worksheet visible is to unprotect the workbook. In frustration and on a lark I tried .Sheets("items").Visible = True and it worked. These kind of intermittent errors in Excel VBA are very frustrating. Can anyone tell me what I am doing wrong?

    Thanks.


    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello colinnwn,

    I am not sure what your question is. I can tell you that the Excel constant xlVisible is equal to -1. The boolean value True also equals -1. So in this case, it doesn't matter which one use.

    Sincerely,
    Leith Ross

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    The property you want is Hidden, not Visible, and its enumerations are xlSheetVisible, xlSheetHidden, and xlSheetVeryHidden.

    Edit:

    xlVisible = 12, not 1.

    xlSheetVisible = 12
    Last edited by shg; 01-06-2009 at 08:08 PM.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434
    my object browser says

    xlVisible = 12
    xlSheetVisible = -1
    Cheers
    Andy
    www.andypope.info

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302
    Quote Originally Posted by shg View Post
    The property you want is Hidden, not Visible
    The Worksheet class does not have a Hidden property, but does have a Visible one. The problem is just the constant, unless I'm going nuts (again).

  6. #6
    Registered User
    Join Date
    01-06-2009
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2003
    Posts
    2

    Cool Ah ha...

    Thanks romperstomper, that makes more sense. I knew the visible property worked previously. I don't remember changing the code to xlvisible vs. xlsheetvisible, but the fact xlsheetvisible enumerates to the same thing that ended up working for me (true), is rational.

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Quote Originally Posted by Andy
    my object browser says

    xlVisible = 12
    xlSheetVisible = -1
    That was a typo, sorry -- the point I was trying to make was that they were different.
    Quote Originally Posted by romperstomper
    The Worksheet class does not have a Hidden property, but does have a Visible one. The problem is just the constant, unless I'm going nuts (again).
    That was not a typo, it was a brain cramp.

    Two errors in one post ...
    Last edited by shg; 01-09-2009 at 03:51 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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