+ Reply to Thread
Results 1 to 19 of 19

VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matches en

  1. #1
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Cool VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matches en

    Hi everyone,

    I am stuck with the problem where i am trying to have my workbook hide all sheets by using xlsheetveryhidden but i struggle to have the workbook then unhide sheet where the sheet name matches environment username. any help would be appreciated.
    the below code shows sm1212 and rw1212 as usernames, my login windows ID is sm1212 so when i login team dash and sm1212 should be the only sheets i can view.


    Please Login or Register  to view this content.
    thanks,

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Have you tried this?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Quote Originally Posted by Norie View Post
    Have you tried this?
    Please Login or Register  to view this content.
    Thanks for the suggestion By implementing that suggested code i get an error "run-time error '438': object doesn't support this property or method.... not sure where to go with it now lol

    >
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Oops, missed the .Visible bit, which might be a bit important.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Excellentio! it works great thank you !

    i was also wondering, how can i make it so that upon wthe workbook opening this macro is automatically ran.. im looking to have it so that when the user opens it only the page permitted to them is viewable. as it currently stands they can see everything until the macro runs lol

  6. #6
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    To debug you can use this.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Thanks for ther code guys, is the below looking good? my next step is automatically having the macro run without being prompted when workbook is opened. is this possible?

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    What are the users being prompted for?

  9. #9
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Quote Originally Posted by Norie View Post
    What are the users being prompted for?
    So when the workbook opens i want to make it so that only the sheet name that matches their windows ID and the sheet called Team Dash is showing, but i need it done autmoatically because it's going to have my teams stats in the workbook and i dont want them viewing each others pages, only their own and the overall team dash. (saves office politics around embarrassment of poor stats etc)

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Sorry I'm a bit confused, if you want code to run when a workbook opens you put it in the workbook's Open event and you've just posted code for that.

  11. #11
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Ah ok, then something isn't working.. when i switch to my colleagues computer to open the sheet after i save it, the macro does not run and all sheets are visible until i manually go in and run the macro lol

  12. #12
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    omg!! sory for the confusion, i hadn't set the worksheet from General to Workbook .. that solved the problem lol you guys were awesome thanks for the help!!

  13. #13
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Try this in your workbook_open

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    this code works perfectly however - all sheets are visible until the excel documents " enable content" has been clicked when it pops up, on the occasion where this does not pop up the macro runs perfectly, but i have no idea how to stop them being bale to click on all the sheets until the "enable content" has been clicked any ideas?

  15. #15
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche


  16. #16
    Forum Contributor
    Join Date
    09-16-2009
    Location
    Dallas, TX
    MS-Off Ver
    Office 2013
    Posts
    107

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Can you hide all the sheets by default (except the dashboard) and display the user's page when macros are enabled?

  17. #17
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    great work Vraag, in the end i ended up using the below code.

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    05-16-2015
    Location
    Scotland
    MS-Off Ver
    2010
    Posts
    19

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    Ended up with this code instead Vraag, any idea's on how to have it recognise my ID only to unhide all sheets on open without it leaving the sheets open on any save?

    Please Login or Register  to view this content.

  19. #19
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: VBA to hide all sheetson workbook open, but then unhide sheets where sheet name matche

    try this

    Please Login or Register  to view this content.

+ 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. [SOLVED] Hide and Unhide rows on multiple sheets based on a validation list on a single sheet
    By bbarth in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-30-2015, 02:10 PM
  2. How to auto hide/unhide sheets in excel workbook based on cell input?
    By bensaps10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2014, 09:57 AM
  3. [SOLVED] Hide/Unhide sheets based on text result of IF Formula in cell in another sheet
    By yukinosei in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-16-2014, 01:17 PM
  4. Hide/Unhide rows on multiple sheets when dropdown selected from sheet 1
    By tammhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-02-2012, 10:33 PM
  5. Capture cells from one sheet into another. Hide/Unhide Sheets
    By jj72uk in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-12-2009, 08:28 PM

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