Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Using a Single Password for Multiple Workbooks.

Using a Single Password for Multiple Workbooks

Written by Allen Wyatt (last updated October 3, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

Bill has a set of multiple workbooks that he frequently uses as a suite. To prevent prying eyes from the contents of these workbooks, he has set a password for each of them. Bill uses a menu workbook as a gateway to the other workbooks in the suite. The workbook contains hyperlinks to the individual workbooks, providing him with quick access to the workbooks in his suite.

Since Excel protects, via password, each workbook on a file-level basis, whenever Bill clicks a hyperlink, he needs to enter the password for the workbook he is trying to access. He wonders if there is a way to simply enter the password once (it is the same password for all of the workbooks in his suite) and have access to all the workbooks without the necessity of repeatedly entering the password.

The short answer is that this cannot be done since Excel treats each file separately. Switch to a separate file via your hyperlink, and Excel once again asks for the password. There are only two possible ways to avoid the annoyance. The first is to combine all the separate workbooks into a single workbook. This may not be an optimal solution, for any number of reasons. (For instance, you may need to distribute individual workbooks to other users. If you combine all the workbooks into one, you remove this capability.)

The other solution is to use a macro to handle switching between workbooks, rather than using hyperlinks. There are many ways that such a macro system could be set up, but one simple way that mimics the hyperlink method is to create a new worksheet that will act as your "gateway." In the cells where you would have added hyperlinks, instead place the full path and filename of each workbook you want to link to. You should end up with a list of file specifications for your workbooks.

Now, right-click the sheet tab of this new worksheet. Excel displays a Context menu from which you should select View Code. This displays the VBA Editor, with the code pane displayed for the worksheet. Enter the following macro into the code pane:

Private Sub Worksheet_BeforeDoubleClick _
  (ByVal Target As Excel.Range, Cancel As Boolean)
    Dim sPW As String
    Dim sFile As String

    sPW = "password" 'Change to your password
    sFile = Target.Value
    If sFile <> "" Then
        If Dir(sFile) <> "" Then
            Workbooks.Open _
              FileName:=sFile, _
              password:=sPW
            Cancel = True
        End If
    End If
End Sub

The only thing you should have to change in the code is the password you want used for the workbooks you are accessing. (The code assumes that the same password is used for all of the workbooks.)

Press Alt+Q to exit the VBA Editor, and you are back at your worksheet. Save the workbook, and then double-click any of the cells containing the path and filenames. What Excel does is to then pass control to the macro which grabs the path and filename and then opens that workbook.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8109) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Using a Single Password for Multiple Workbooks.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Entering a Page Break from the Keyboard

Need to force Word to move text to the top of the next page? It's easy when you use the keyboard shortcut for a page break.

Discover More

Getting Rid of the Ctrl+Click Message

When you add a hyperlink to a document, you can later click that link to display whatever is linked to. Well, you ...

Discover More

Entering Dates in Excel

When you type information into a cell, Excel tries to figure out what type of information you are entering. If Excel can ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Creating Workbooks for Individual Worksheets

If you have a workbook with lots of worksheets, you may want those worksheets to be saved off in individual workbooks. ...

Discover More

Comparing Workbooks for Differences

When working with copies of workbooks--particularly copies derived from a common ancestor workbook--you may be interested ...

Discover More

Noting the Workbook Creation Date

You may want to add, to your worksheet, the date on which a particular workbook was created. Excel doesn't provide a way ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 3 + 7?

2023-10-03 06:04:34

Brian Dorey

I think that Bill also needs to put a password on the VBA Project window, otherwise the prying eyes can simply open the menu workbook look at the VBA code and will see the password. This is easily done from the VBA Project - Project Properties. One point to note when the VBA Project Editor is opened (and the correct password given at the prompt), the password is not removed. So when he exits the VBA Editor the project will still be password protected.


2019-12-28 09:19:39

Peter Atherton

Annie
Instead of using the button to call the macro you can call a enter password macro wich then call the main macro. The following gives the user 3 chances to enter the macro before closing.

Sub CallBoldKeywords()
Dim sPW As String, sStr As String, counter
sPW = "password" 'Change to your password
sStr = Application.InputBox("Enter the password", "EmboldenKeyWords", Type:=2)
Do Until sStr = sPW
counter = counter + 1
If counter = 4 Then Exit Sub
sStr = Application.InputBox("Enter the password", "Embolden Key Words", Type:=2)
Loop
' Prepare the range
Range("C16") = Range("C18")
[c16].Select
'call the macro
Application.Run "MiscJune2019.xlsm!BoldKeyWords"
End Sub


2019-12-27 14:08:12

Annie Anderson

Hi, Allen - thanks for sharing Excel tips and tricks. This may be a little off-topic? I have a workbook with multiple worksheets for monthly budget reporting. One of the worksheets has formatting macros with buttons for each month. I've tried to password protect just that worksheet so our customers can't click the macro button, to no avail. Even though the worksheet is password protected, people can still click the macro. Is there a way to protect a worksheet with macro buttons? Thanks much.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.