Solved

How can I set password for a sheet in excel

Posted on 2016-10-28
4
70 Views
Last Modified: 2016-10-28
Hello experts,

I need to give password to one of the sheets in my excel file. I have two excel sheets in my workbook (Input, and Report).

I want to give password to "Report" sheet.

thanks for your help!
0
Comment
Question by:tony01excel tony
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Accepted Solution

by:
Yamaafg earned 400 total points
ID: 41863920
Hi,

Try below code. Change the password from 123456 to whatever you would like it to be.You need to enter this code in the main workheet in vba and save your file as as xlsm.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
'to password protect Report Sheet
Dim xSheetName As String
xSheetName = "Report"
If Application.ActiveSheet.Name = xSheetName Then
    Application.EnableEvents = False
    Application.ActiveSheet.Visible = False
    xTitleId = "Please Enter The Password"
    response = Application.InputBox("Password", xTitleId, "", Type:=2)
    If response = "123456" Then
        Application.Sheets(xSheetName).Visible = True
        Application.Sheets(xSheetName).Select
    End If
End If
Application.Sheets(xSheetName).Visible = True
Application.EnableEvents = True
End Sub
0
 
LVL 19

Assisted Solution

by:Zaheer Iqbal
Zaheer Iqbal earned 100 total points
ID: 41863933
0
 

Author Closing Comment

by:tony01excel tony
ID: 41863940
Great, thanks for the quick help guys. The first solution with vba code worked well.
1
 
LVL 19

Expert Comment

by:Roy_Cox
ID: 41864063
That code does not protect the sheet at all!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question