show different information based on a password for a workbook

avgrin

New Member
Joined
Nov 11, 2014
Messages
17
How to show to sales people only individual reports based on a password to a workbook. The workbook contains a sheet with sales data for the company; by selecting a sales rep in a pivot table filter, it produces necessary reports. How to show to the sales manager all the reports, but to each rep only individual reports?

Thank you,
Avgrin
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi

Sub Z9_Start()'
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next

Dim MyPassword As String
MyPassword = "QWERTY"

Sheets("check").Visible = True
ActiveSheet.Unprotect (MyPassword)





Sheets("check").Select
ActiveSheet.Unprotect (MyPassword)

Dim strName As String

'InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context])
strName = InputBox("Enter Password", "Department of Statistics")
'Exit sub if Cancel button used or no text entered
If strName = vbNullString Then Exit Sub


Sheets("check").Range("A1").Select
ActiveCell = strName

If Sheets("check").Range("A1").Value = "RED" Then

Sheets("RED").Visible = True
Sheets("RED").Select
ActiveSheet.Unprotect (MyPassword)

Else
If Sheets("check").Range("A1").Value = "BLUE" Then

Sheets("BLUE").Visible = True
Sheets("BLUE").Select
ActiveSheet.Unprotect (MyPassword)

Else
If Sheets("check").Range("A1").Value = "GREEN" Then

Sheets("GREEN").Visible = True
Sheets("GREEN").Select
ActiveSheet.Unprotect (MyPassword)



Else
MsgBox "Unable to access data" & vbNewLine & "Incorrect Password", , "Department of Statistics"
Sheets("start").Select

End If
End If
End If
Sheets("check").Visible = False


End Sub

I think this code will help you with that

so, predefined passwords are
"BLUE" -> will open sheet named BLUE
"RED" -> will open sheet named RED
"GREEN" -> will open sheet named GREEN

if smth else is entered error message is displayed

and also you have to protect workbook to disable unhide/hide sheets manualy
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,877
Members
449,056
Latest member
ruhulaminappu

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