+ Reply to Thread
Results 1 to 5 of 5

Sheets(1).visible=False not working.

  1. #1
    Registered User
    Join Date
    08-09-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    49

    Sheets(1).visible=False not working.

    I have made an longer Workbook_Open code and in the end of that code I have asked the code to make some sheets not visible (sheets(1).visible=false), but it doesn't work and they remain unhidden. WHY?

    Is it because I have uset select or activate earlier in the code?

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Sheets(1).visible=False not working.

    Hi, esbenhaugaard,

    if tested on it´s own the command runs fine (although I would recommend using either xlSheetVisible, xlSheetHidden or xlSheetVeryHidden). Maybe you can post the code or supply a workbook as a sample to have a more detailed look at the code and maybe find out why the line fails (no protection for the structure of the workbook?).

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    08-09-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Sheets(1).visible=False not working.

    Hey. Thanks for the reply. I will look upon the opportunity to use xlSheetVisible etc. I am quite new to VBA and I discover new opportunities every time, thanks.
    I have attached my workbook here. The Workbook_Open is placed in ThisWorkbook.

    As you probably can see, I have used some ‘Export K’ to folder which of cause doesn’t run smooth on your computer 
    Attached Files Attached Files
    Last edited by esbenhaugaard; 11-25-2012 at 09:43 AM.

  4. #4
    Registered User
    Join Date
    08-09-2012
    Location
    Copenhagen
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Sheets(1).visible=False not working.

    I have found the mistake. I have made and Exit sub earlier!!! Big mistake. hihi. Why is there an advantage by using xlsheetVisible?

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Sheets(1).visible=False not working.

    Hi, esbenhaugaard,

    let´s start with a more general remark. You dimmed
    Please Login or Register  to view this content.
    Except f1 (Single), Rng (Range), oCell (Range), and LR (Long) all other variables on that line are of type Variant. It´s no great point but I like to know of which Type my Variables are, and I like them to give me a hint on which object they will be needed (I can figure that out for Rng, oCel and LR but not for the rest).

    Later on in the code you set x to the Monthname of the actual date
    Please Login or Register  to view this content.
    You could use the Format-Command for that as well:
    Please Login or Register  to view this content.
    Okay, the computer I work on doesn´t have a drive D so a lot of errors came up in the next part regarding the pictures so I commented a lot of that code.

    Setting the Date on Sheet Karrusel:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Why is there an advantage by using xlsheetVisible?
    True and False combine for 2 states but using the constants gives you a third one which can only be made visible via VBA-Code or from the VBE. That´s just a matter of taste.

    Sorry for my late answer as I have started this post a very long time ago before you actually have found the error yourself (it´s a lot of code to look at ).

    Ciao,
    Holger

+ 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