• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Give Access to Certain Worksheets

cyliyu

Member
I created a Main Menu to ease users to access to a particular worksheet when the correct button is clicked.
But I would like to control not to allow them to access all the worksheets.
For e.g. group A will have access to SheetA & AAList but no access to AChart sheet.

Any help, please?
 

Attachments

  • Sample.xlsm
    47 KB · Views: 8
I have created the groups and users access right in sheet 1.
Not sure is this the best way to define the access right.
Open for suggestion.
 

Attachments

  • Sample.xlsm
    45.6 KB · Views: 3
If you don't know the username for each of your participants, then run this short macro on each user's PC and it will tell you the Windows UserName.

Code:
Sub FindUser()
Dim User As String
User = Environ("UserName")
MsgBox (User)
End Sub
 
cyliyu
Note: I asked usernames which Excel knows/uses,
not names which 'parents' has given!
Ex if Your username is on that list, then You could see something ...

Ok, The usernames was updated.
It consists of 3 groups. Thanks.
 

Attachments

  • Sample.xlsm
    53.4 KB · Views: 3
Ok, The usernames was updated.
It consists of 3 groups. Thanks.

Attached the wrong file. This should be the right one.

I read your code and understand as long as the user's name (network-Login ID) are input into column C in "GRPS" sheet, the users access right works.
How do I control which worksheet they have the access?
 

Attachments

  • Sample1.xlsm
    53.6 KB · Views: 3
How do I control which worksheet they have the access?
If there is something (ex 'X' in cell) then
that user has access to sheet which has named in 'header'.
Ex the 1st name has access to 'SheetN', 'SheetP', 'Achart', 'Cchart'.
No matter of 'groups', just UserNames (C-column)matters!

Screen Shot 2017-09-26 at 10.04.37.png
NOTE!
if You'll change layout of that 'GRPS'-sheet,
then You have to change code too!
... or that code won't work .. at all!


btw ... interesting UserNames, but of course those are possible too!
Have You tested what would be Yours with 'Sub TextBox_Click'?
 

Attachments

  • Sample1.xlsm
    53.1 KB · Views: 7
I got the "approved" users work great in your last attached file but not the access to a particular sheet.

Even remove all the "X" in the GRPS cells, the approved users still can access all the worksheets.

May I know what does .range("9:9") means in this statement?

xUN = WorksheetFunction.Match(shtname, Sheets("GRPS").Range("9:9"), 0)
 
.Range("9:9") is Your 'Sheet-name row' (before it was 4, now it's 9) - Okay?
With yUN- and xUN-values, it checks if that user/sheet -combination marked.
If marked then user can see that sheet.
If You have taken away ALL "X" ... hmm
... then even famous ANYBODY cannot see anything!
... if You add "X" in every cell, then EVERYBODY can see everything!
> I added one more sub for getting those usernames.
 

Attachments

  • Sample1.xlsm
    56.5 KB · Views: 4
Code:
.Range("9:9") is Your 'Sheet-name row' (before it was 4, now it's 9) - Okay?
Yes, I noticed you have changed from 4 to 9. just like the C:C column to search for the users.

I got both the MsgBox "You Selected An Unknown Sheet!" & "You Are Unknown User!" work great but not the MsgBox "You Don't Have Permit To See That Selection"

I screenshot my testing results as follow:-
1) GRPS Settings for myself, only allow to access Dashboard, SheetA and SheetC
upload_2017-9-26_20-56-21.png

2) But when I click on the Partlists or SheetB, I am still allow to access this 2 sheets.
upload_2017-9-26_20-58-26.png upload_2017-9-26_21-0-45.png
 
Last edited:
Are those two sheet 'hidden' before You start to clicking?
In the beginning ALL sheets have to be 'hidden' or more!
not this way!
Screen Shot 2017-09-26 at 16.25.32.png
and are those cells REALLY EMPTY ( even space is too much! )
 
Yes, I have enabled back the code and left only the "Home" and "GRPS" sheets.
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
If (Sh.CodeName <> "Sheet1") And (Sh.CodeName <> "Sheet13") Then
Sh.Visible = xlSheetVeryHidden
End If
End Sub

I also make sure the cells really empty, and even tried to change the format to "Text" or "General" etc. but just couldn't get it work.
 

Attachments

  • Sample1.xlsm
    57.4 KB · Views: 3
Ouch! - Now I got it!
One 's' missed - sorry!
... and of course that 'GRPS' should be hidden too.
 

Attachments

  • Sample1.xlsm
    58.4 KB · Views: 8
Back
Top