+ Reply to Thread
Results 1 to 12 of 12

VBA Protect userInterfaceOnly and hidden cells?

  1. #1
    Registered User
    Join Date
    08-30-2024
    Location
    Ottawa
    MS-Off Ver
    360
    Posts
    8

    VBA Protect userInterfaceOnly and hidden cells?

    Hello, I am using Excell for a personal project to learn a bit of Excell and VBA.

    The Personal project is a simple TTRPG automated character sheet and I use protection just so the players don't mess with the cells that are used only for logic purposes such as the racial trait tables tables and etc. I want to hide the second worksheet called "GeneralTables", so the players can't see the tables, and the second page of the "Character Sheet" worksheet, so that players can share their screen without revealing their Character secret details that are on the second page of the Character sheet.

    I have a ActiveX checkbox that protects and Unprotects the worksheets using the following VBA code, but the cells marked as Hidden are still visible. Is there an option to make them hide even if I am using the userinterfaceonly flag?

    PHP Code: 
    Private Sub CheckBox1_Click()
        If 
    CheckBox1.value True Then
            Worksheets
    ("Character Sheet").Protect "1234"userinterfaceonly:=True
        
    Else
            
    Worksheets("Character Sheet").Unprotect "1234"
        
    End If
    End Sub 

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,003

    Re: VBA Protect userInterfaceOnly and hidden cells?

    Can you be more specific about what you mean by "cells marked as Hidden"? How are they marked as hidden? When are they hidden and when are they visible?

    1. Sheet protection is unrelated to whether cells are hidden or visible.

    2. You can't make individual cells hidden, you can only make entire columns or entire rows hidden.

    So because of these two facts, I can't make sense out of "cells marked as Hidden are still visible".
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-30-2024
    Location
    Ottawa
    MS-Off Ver
    360
    Posts
    8

    Re: VBA Protect userInterfaceOnly and hidden cells?

    Oh, maybe I assumed wrong, but I thought the checkbox "Hidden" under Format Cells -> Protection meant that the cell would not be visible if the sheet is protected. Did I completelly misunderstand this?

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,016

    Re: VBA Protect userInterfaceOnly and hidden cells?

    Yes, I'm afraid you did. That checkbox only hides the contents of the cells in the formula bar. It's designed to stop people seeing what formulas are used in cells.
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Registered User
    Join Date
    08-30-2024
    Location
    Ottawa
    MS-Off Ver
    360
    Posts
    8

    Re: VBA Protect userInterfaceOnly and hidden cells?

    So, there is no way to hide some cells or at least a full worksheet when I distribute the final document?

    I mean, I am working on something silly by what if you need to reference price tables or some information that is not for the end users eyes?

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,003

    Re: VBA Protect userInterfaceOnly and hidden cells?

    You could put the secret data in hidden columns or hidden rows. The best practice for underlying data that you don't want your user to see is put it on another sheet and hide that sheet altogether.

    There are additional layers of "security" but Excel's features are for compliant users, not malicious ones. They can be broken.

    If you want more advice specific your file, you can attach your file here and explain in more detail what you need to do.

  7. #7
    Registered User
    Join Date
    08-30-2024
    Location
    Ottawa
    MS-Off Ver
    360
    Posts
    8

    Re: VBA Protect userInterfaceOnly and hidden cells?

    Humm, ok, I was able to hide second sheet by right clicking and choosing hide. I guess I can just do that to the files that I send to the players.

    Thank you all for your help.

  8. #8
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,551

    Re: VBA Protect userInterfaceOnly and hidden cells?

    Bear in mind that setting a sheet to xlVeryHidden can only be done in the VBA Editor. And it can be unset there too. Therefore, having set the sheet(s) to xlVeryHidden, you need to protect the VBA Project with a password.

    That said, no amount of hiding sheets can prevent people from accessing the data, even if it is on a hidden sheet, if they know it is there and where to look. So,you should still lock and hide the formulae cells and protect the sheet with a password.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  10. #10
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: VBA Protect userInterfaceOnly and hidden cells?

    Quote Originally Posted by TMS View Post
    Bear in mind that setting a sheet to xlVeryHidden can only be done in the VBA Editor. And it can be unset there too. Therefore, having set the sheet(s) to xlVeryHidden, you need to protect the VBA Project with a password.

    That said, no amount of hiding sheets can prevent people from accessing the data, even if it is on a hidden sheet, if they know it is there and where to look. So,you should still lock and hide the formulae cells and protect the sheet with a password.

    Just so we're clear the purpose of my post was if those compliant users mentioned in #6 don't see something in an unhide list then that would be better than having it listed there.
    Last edited by skywriter; 09-02-2024 at 06:25 PM.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,551

    Re: VBA Protect userInterfaceOnly and hidden cells?

    Quote Originally Posted by skywriter View Post
    Just so we're clear the purpose of my post was if those compliant users mentioned in #6 don't see something in an unhide list then that would be better than having it listed there.
    No disagreement at all. I'm just trying to cover the bases. You never really know how "compliant" a user might be. Accidental discovery and curiosity can take you a long way.

    Let's say I have a formula on another worksheet that refers to the (Very) Hidden sheet. That tells me a) that there is a sheet there but, for some reason, I can't see it. BUT, I can see the value (static or calculated) that is in that cell. And I can then determine if there is a formula in that cell, indeed, what that formula might be. That might point me at other specific cells or I might just looking generally.

    So, thinking about it, it's actually the sheet that refers to the hidden sheet that needs to have formulae locked and hidden with the sheet protected.

    So, no criticism intended. I agree that Very Hidden is better than just Hidden, and more difficult to access. I just think that there's a bit more to do, even for compliant users. If you're going to do it all, you best do a thorough job (IMO).

  12. #12
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    365 Version 2409
    Posts
    2,789

    Re: VBA Protect userInterfaceOnly and hidden cells?

    So, no criticism intended. I agree that Very Hidden is better than just Hidden, and more difficult to access. I just think that there's a bit more to do, even for compliant users. If you're going to do it all, you best do a thorough job (IMO).
    No worries I just wanted to clarify my motivation was 6StringJazzer's post and perhaps since we're talking about hiding stuff veryhidden might be better than regular hidden.
    I agree with you both regarding security.
    Thanks for the rep.

+ 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] Protect workbook for UserInterfaceOnly
    By Jerbinator in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-28-2019, 12:00 PM
  2. Protect WS and allow Userinterfaceonly, AllowFiltering, EnableOutlining
    By dmarsh68 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-09-2017, 12:24 PM
  3. Protect UserInterFaceOnly:=True ONLY to VISIBLE worksheets WITHOUT a password
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-07-2017, 10:20 AM
  4. Protect(UserInterfaceOnly)
    By waqar1239 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2017, 11:44 PM
  5. Sheets.Protect UserInterfaceOnly parm not working for me
    By Weebie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-17-2007, 05:42 PM
  6. .protect userinterfaceonly:=true not working?
    By dreamz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2006, 07:31 PM
  7. Protect UserInterfaceOnly + Control deletion of file in same folder
    By Alex Hatzisavas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2005, 07:02 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