Password protect worksheets

siafc1

New Member
Joined
Jan 15, 2005
Messages
20
Hi,

Firstly, this is a college project so it doesn't matter if the workbook isn't 100% secure (although in excel I've heard that isn't possible anyway).

I want to protect certain worksheets with password protection. The basic excel protection isn't satisfactory because it ruins my macros. I want to simply protect access to a worksheet with a password.

For example my 5th sheet (named "Accounts") is one I definately want to protect with a password.

The tricky bit:

To access the "Accounts" sheet, I want the user to click on a button that has a macro attached to it that takes them to "Accounts" (I've already got this) rather than the tabs at the bottom.

So is there a way in which when the user clicks on the "Accounts" macro, they have to type in a password before they get to "Accounts"?

ps. Also, is there any way I can get rid of the tabs at the bottom so the user can only use my macros to navigate around the workbook?

thanks, any help would be appreciated greatly.
 

Excel Facts

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

Code:
Sub getaccounts()
    Sheets("Accounts").Select
    Sheets("Accounts").Unprotect
End Sub
The above is a simple macro to make a user to use password to unprotect the sheet (named accounts in this regard). (if he is familiar to Excel ways only as I do. :biggrin: )
And regarding the tabs at bottom... I think help is on the way
 
Upvote 0
To hide all sheets except for your macro sheet:

Code:
Private Sub Workbook_Open()
    Dim ws As Worksheet
        '   Hide worksheet tabs
        ActiveWindow.DisplayWorkbookTabs = False
            
        For Each ws In ActiveWorkbook.Worksheets
            '   Macro navigation sheet
            If ws.Name <> "Dashboard" Then
                ws.Visible = xlSheetHidden
            End If
        Next ws
        
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ActiveWindow.DisplayWorkbookTabs = True
End Sub
To get to the account sheet and require a password (using an ActiveX button):
Code:
Private Sub CommandButton1_Click()
    Dim ans As String
        ans = InputBox("Please enter the password", "Password required")
        
        If ans <> "yomama" Then
            Exit Sub
        Else
            With Sheets("Accounts")
                .Visible = True
                .Activate
            End With
        End If
End Sub
HTH,

Smitty
 
Upvote 0

Forum statistics

Threads
1,203,080
Messages
6,053,410
Members
444,662
Latest member
AaronPMH

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