User ID based excel macro for performance data

Rajchettiar

New Member
Joined
Apr 27, 2021
Messages
1
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi ,
I manage performance data of a large team. How can share full data file to the entire team in such a way where
1. If a team members opens the file he can only view his performance data.
2. A Team leader can view only his teams data.
3. Unit head/ Admin can view the entire data.
In my organization every individual has a unique log in ID.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I'm giving you one possible solution. Except for Main sheet, the rest of sheets in workbook will be hidden and cannot be unhide unless through VBA.
Once password is entered. the person will have access it whichever sheet the person is allowed.

One routine is event routine when workbook is opened, installed in ThisWorkbook module. the other one is in regular module.

Modify the code to your need.
VBA Code:
Private Sub Workbook_Open()
Dim ws As Worksheet

For Each ws In Sheets
    If Not ws.Name = "Main" Then
        If ws.Visible = xlSheetVisible Then
            ws.Visible = xlSheetVeryHidden
        End If
    End If
Next

Call Test

End Sub
VBA Code:
Sub Test()

Const AdminPwd = "1234"
Const TeamLeaderPwd = "123"
Const MemID01Pwd = "12"
Dim Pwd As String
Dim ws As Worksheet
Dim wsMain As Worksheet
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet

Set wsMain = Sheets("Main")
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets("Sheet3")

Pwd = InputBox("Enter Password")
Select Case Pwd
    Case AdminPwd
        For Each ws In Sheets
            ws.Visible = xlSheetVisible
        Next
    Case TeamLeaderPwd
        ws1.Visible = xlSheetVisible
        ws3.Visible = xlSheetVisible
    Case MemID01Pwd
        ws1.Visible = xlSheetVisible
End Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,483
Messages
6,125,063
Members
449,206
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top