The Excel functions to hide and reveal columns are often used, making it simple to conceal and reveal them. However, there are occasions when you need to hide some columns that contain important information that you don’t want others to see. In this article will show you how to Hide Columns in Excel with Password.
Download Practice Workbook
You may download the following Excel workbook for better understanding and practice it by yourself.
2 Handy Approaches to Hide Columns in Excel with Password
Your worksheet’s columns holding data that you do not need to see or do not want to print can be hidden. These two techniques will show you how to use the Review tab and VBA Code to Hide Columns in Excel with a Password. Let’s suppose we have a sample data set.
1. Utilizing Review Tab to Hide Columns in Excel with Password
In this first method, you will learn how to hide columns in Excel with a password utilizing the Review tab.
Step 1:
- Firstly, click on column D and then click Shift to select column E as well.
- Secondly, right-click the mouse button.
- Thirdly, click on the Hide option to hide the D and E columns.
Step 2:
- Now, you can see the D and E columns are hidden below.
Step 3:
- Firstly, go to the Review tab.
- Secondly, click on the Protect Sheet command.
- Thirdly, to protect the sheet columns, you can enter a password to unhide and hide the D and E columns.
- Finally, click OK.
Step 4:
- Here, you will reenter your password.
- Then, click OK.
Step 5:
- When you need to unhide the D and E columns, go to the Review tab again.
- Now, click on the Unprotect Sheet command.
- Besides, click OK.
Step 6:
- In this step, you will keep your cursor here, which is marked by a red rectangle.
- Now, Double-click on the red marked position.
Step 7:
- Finally, you will notice that columns D and E are unhidden.
Read More: How to Hide and Unhide Columns in Excel (7 Quick Methods)
2. Applying VBA Code to Hide Columns in Excel with Password
In this final session, we will create a VBA Code to Hide Columns in Excel with a Password using the Developer tab.
Step 1:
- At first, we will use the Developer tab.
- Then, we will select the Visual Basic command.
Step 2:
- Here, the Visual Basic window will open.
- After that, from the insert option, we will choose the new Module to write a VBA Code.
Step 3:
- Now, paste the following VBA code into the Module.
- To run the program, click the “Run” button or press F5.
Sub Hide_Columns_withPassword()
'Declaring Variables
Dim Mypassword
Dim zAddress As String
'Selecting columns D and E
zAddress = "D:E"
'Selected columns will be hidden
Application.ActiveSheet.Columns(zAddress).Hidden = True
tryagain:
'Enter the password here
Mypassword = InputBox("Enter Password", "Password")
If Mypassword = "Bishawajit" Then
' After entering the correct password, columns will be shown
Application.ActiveSheet.Columns(zAddress).Hidden = False
MsgBox ("Correct")
Else
'If password is incorrect, you can try again by clicking Yes option
If MsgBox("Password incorrect, try again?", Yes Or No, "Wrong password") = Yes Then
GoTo tryagain
Application.ActiveSheet.Columns(zAddress).Hidden = True
End If
End If
End Sub
VBA Code Breakdown
- Firstly, we call our Sub Procedure as Hide_Columns_withPassword().
- Secondly, we declare our variables asDim Mypassword and Dim zAddress As String.
- Then, we select the D and E columns and put them in a variable as zAddress = “D:E”.
- And, D and E columns will be hidden in our active sheet as ActiveSheet.Columns(zAddress).Hidden = True
- Now, we declare our password as Mypassword = InputBox(“Enter Password”, “Password”).
- After running the program, you will enter the correct password to unhide the D and E columns as If Mypassword = “Bishawajit”.
Step 4:
- After running the program, this window will open and you will see the D and E columns are hidden.
- Now, you will input your correct password.
- Then, click OK to unhide the D and E columns.
Step 5:
- Here, you will see the D and E columns unhidden below.
- And if your input password is correct, this given window will open.
- Then, click OK.
Step 6:
- If your password is incorrect, this window will open.
- Here you will see the D and E columns are still hidden.
- Then, click OK to re-enter your correct password.
Read More: Excel VBA to Hide Columns Based on Criteria (6 Useful Examples)
Conclusion
In this article, I’ve covered 2 handy methods to Hide Columns in Excel with Password. I sincerely hope you enjoyed and learned a lot from this article. Additionally, if you want to read more articles on Excel, you may visit our website, Exceldemy. If you have any questions, comments, or recommendations, kindly leave them in the comment section below.
Related Articles
- How to Group and Hide Columns in Excel (3 Easy Methods)
- Unhide All Columns with Excel VBA (8 Examples)
- How to Hide Unused Columns in Excel (5 Quick Tricks)
- Unhide Columns Is Not Working in Excel (4 Issues & Solutions)
- Excel VBA: Hide Columns Based on Cell Value (15 Examples)
- How to Hide Multiple Columns in Excel (5 Easy Methods)
- Hide Rows and Columns in Excel (10 Ways)
HI Bishawajit, this is really great. On the macro solution, is it possible to re-write so that you password protect “grouped” columns instead of hidden columns? Basically, I want it to be required to type in a password when clicking the “+” sign on grouped columns. Thank you much!
Thank you so much, Peter, for your comment.
You will find your solution in the below steps. Please follow the steps accordingly.
Steps:








• Firstly, go to the Data tab.
• And, select the group option.
• Now, you will see here the plus (+) sign.
• Here, we have grouped the 5th, 6th, and 7th rows.
• Then, go to the Review tab.
• And, select the Allow Edit Ranges option.
• After that, choose the ranges.
• And, type the password and click OK.
• Retype the password and click OK.
• Now remove this window.
• Firstly, go to the Review tab.
• Secondly, select the Protect Sheet option.
• Now, write your password.
• And, click OK.
• Then, retype your password and click OK.
• So, if you click on the plus (+) sign, it will show you the given result you want.