encrypt a tab to prevent view or opening

NoelD

New Member
Joined
Apr 16, 2015
Messages
34
Office Version
  1. 2019
Platform
  1. Windows
Is there a way to protect a tab in a workbook from being visible to some shared users
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
you make the sheet "veryhidden" which can only be done ( and undone) using vba and if you then password protect the vba project that is going to stop all but the very determined
code likethis:
VBA Code:
Sheets("Sheet1").Visible = xlVeryHidden
 
Upvote 0
Taking it one step further from offthelip's post, I use a couple of different methods depending on the need. As offthelip stated, use the xlveryhidden attribute in a workbook_open script. Then on one of my pages, I designate a cell for a "password". When the user enters that password, it will unhide the sheet(s) accordingly.
VBA Code:
Private Sub worksheet_change(ByVal target As Range)

If Not Intersect(target, Sheet11.Range("AuditCode")) Is Nothing Then
If Sheet11.Range("AuditCode").Value = "Showmethemoney" Then
Application.EnableEvents = false
' Display Audit Sheet
  Sheet12.Visible = xlSheetVisible
  Sheet11.Range("AuditCode").Value = ""
  Sheet12.Activate
End If
End If
Application.EnableEvents = True
End Sub

Alternatively, if you know the user ID's of the people using the sheet, you could use something like the following in a workbook_open script:
VBA Code:
Private Sub workbook_open()
Dim whodis As String
whodis = Environ("UserName")
If whodis = "ThisID" Or whodis = "ThatID" Then
   Sheet11.Visible = xlSheetVisible

End If
End Sub
 
Upvote 0
Thanks for the information, but as i am new to VBA...I cant follow the code.

I want to have a password on one sheet that will open a hidden sheet in a workbook containing 5 sheets
 
Upvote 0
To get this code working, choose a cell where you want the user to enter the password. For mine, I gave it a range name called AuditCode which you'll also see in the vba referenced as range("AuditCode").value:

1679430028473.png


VBA Code:
Private Sub worksheet_change(ByVal target As Range)

If Not Intersect(target, Sheet11.Range("AuditCode")) Is Nothing Then
If Sheet11.Range("AuditCode").Value = "Showmethemoney" Then
Application.EnableEvents = false
' Display Audit Sheet
  Sheet12.Visible = xlSheetVisible
  Sheet11.Range("AuditCode").Value = ""
  Sheet12.Activate
End If
End If
Application.EnableEvents = True
End Sub

This code is to be placed in the sheet where the user would enter the password. In my case it is a 'Defects' sheet:

1679430046640.png


When the user enters the correct password in that field, this will:
Unhide sheet12, then clear out the password field and navigate to sheet12.
 
Upvote 0
You could unhide multiple sheets by adding applicable lines such as:

sheet12.visible = xlsheetVisible
sheet8.visible = xlsheetVisible
sheet9.visible = xlsheetVisible

etc.
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

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