Bỏ qua nội dung chính

Cách đặt password để bảo vệ bảng ẩn trong Excel?

If you have a workbook which contains some important hidden worksheets, and do not allow others to unhide them. Now, you need to set a password to protect the hidden worksheets completely, when other users unhide them, they must enter the password. Do you have any ways to deal with this task quickly and easily in Excel?

Set password to protect hidden sheets with VeryHidden function

Set password to protect hidden sheet with VBA code

Bảo vệ nhiều trang tính cùng một lúc với Kutools for Excel


Set password to protect hidden sheets with VeryHidden function

Normally, you can use the VeryHidden function to hide the worksheets first, and then set a password for them, please do as following steps:

1. Mở sổ làm việc của bạn và giữ Alt + F11phím để mở Cửa sổ Microsoft Visual Basic for Applications.

2. Trong Cửa sổ Microsoft Visual Basic for Applications, Click Xem > Trình khám phá dự án Cửa sổ thuộc tính to hiển thị các ngăn của chúng.

doc-protect-hidden-sheet-01

3. Và sau đó trong Dự án-VBAProject , chọn trang tính mà bạn muốn ẩn và trong Bất động sản , nhấp vào danh sách thả xuống từ Có thể nhìn thấy phần để chọn xlTấmRấtẨn tùy chọn, xem ảnh chụp màn hình:

doc-protect-hidden-sheet-02

4. After making the worksheet veryhidden, you can set a password to protect it. In the Cửa sổ Microsoft Visual Basic for Applications, Click Chèn > Mô-đun để mở một mô-đun trống, sau đó nhấp vào CÔNG CỤ > Thuộc tính VBAProject, xem ảnh chụp màn hình:

doc-protect-hidden-sheet-03

5. Sau đó, trong cửa sổ bật ra VBAProject-Thuộc tính dự án hộp thoại, nhấn Sự bảo vệ tab, và sau đó kiểm tra Khóa dự án để xem box, finally, enter and confirm the password trong Quaword to view project properties , xem ảnh chụp màn hình:

doc-protect-hidden-sheet-04

6. Sau đó nhấn vào OK để thoát khỏi hộp thoại này và đóng Cửa sổ Microsoft Visual Basic for Applications.

7. Lưu sổ làm việc dưới dạng Excel Sổ làm việc kích hoạt macro định dạng và đóng nó để vượt quaword protection take effect.

doc-protect-hidden-sheet-05

8. Next time, when you open this workbook, and want to make the veryhidden sheets be visible, you are requested to enter a password. Xem ảnh chụp màn hình:

doc-protect-hidden-sheet-06


Demo: Set password to protect hidden sheets


Set password to protect hidden sheet with VBA code

To set a password to protect the hidden sheets, I can also talk about a VBA code for you.

1. Ẩn một trang tính mà bạn muốn bảo vệ.

2. Giữ ALT + F11 phím để mở Cửa sổ Microsoft Visual Basic for Applications.

3. Sau đó chọn Sổ làm việc này từ bên trái Trình khám phá dự án, nhấp đúp vào nó để mở Mô-đun, sau đó sao chép và dán mã VBA sau vào Mô-đun trống:

VBA code: Set password to protect hidden sheet

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim xSheetName As String
xSheetName = "Sheet1"
If Application.ActiveSheet.Name = xSheetName Then
    Application.EnableEvents = False
    Application.ActiveSheet.Visible = False
    xTitleId = "KutoolsforExcel"
    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

doc-protect-hidden-sheet-07

Chú thích: Trong đoạn mã trên, Sheet1 của xSheetName = "Trang 1" script là tên trang tính ẩn mà bạn muốn bảo vệ và 123456 trong Nếu response = "123456" thì script is the password that you set for the hidden sheet. You can change them to your need.

4. Now, when you want to show the hidden sheet, a prompt box will pop out to let you enter the password. And this prompt box will appear each time, when you click to show the hidden sheet.

doc-protect-hidden-sheet-08


Bảo vệ nhiều trang tính cùng một lúc với Kutools for Excel

If you want to protect multiple selected or all worksheets of a workbook at once, normally, you need to protect one by one manually in Excel. Nhưng, nếu bạn có Kutools for Excel, Với khả Bảo vệ trang tính tiện ích, bạn có thể bảo vệ chúng bằng một cú nhấp chuột.

Kutools for Excel : với hơn 300 tiện ích Excel phần bổ trợ, dùng thử miễn phí không giới hạn trong 30 ngày

Sau khi cài đặt Kutools for Excel, vui lòng làm như sau:

1. Nhấp chuột Kutools Hơn > Bảo vệ trang tính, xem ảnh chụp màn hình:

2. Trong Bảo vệ trang tính hộp thoại, tất cả các trang tính trong sổ làm việc được liệt kê vào hộp danh sách, vui lòng chọn các trang tính mà bạn muốn bảo vệ. Xem ảnh chụp màn hình:

doc-protect-hidden-sheet-010

3. Và sau đó nhấp vào OK, in the following dialog box, please enter your password and retype it again, then click OK, một hộp nhắc khác sẽ bật ra để nhắc bạn có bao nhiêu trang tính đã được bảo vệ.

doc-protect-hidden-sheet-011

4. Sau đó nhấn vào OK to close the dialogs, and all of the worksheets in the workbook have been protected with the same password.

LƯU Ý Nếu bạn muốn bỏ bảo vệ tất cả các trang tính cùng một lúc, bạn chỉ cần nhấp vào Kutools Hơn > Bỏ bảo vệ trang tínhvà nhập thẻ của bạnword to cancel the protection.

 Tải xuống và dùng thử miễn phí Kutools for Excel Hiện nay !


Các bài liên quan:

Cách bảo vệ nhiều bảng tính cùng lúc trong Excel?

Cách đặt thẻword để bảo vệ sổ làm việc?

Cách bảo vệ/khóa mã VBA trong Excel?

Công cụ năng suất văn phòng tốt nhất

Tăng cường bảng tính của bạn: Trải nghiệm hiệu quả hơn bao giờ hết với Kutools for Excel

Các tính năng phổ biến: Tìm/Đánh dấu/Xác định nội dung trùng lặp   |  Xóa hàng trống   |  Kết hợp các cột hoặc ô mà không làm mất dữ liệu   |   Vòng không có công thức hữu ích. Cảm ơn !
Siêu tra cứu: Nhiều tiêu chí VLookup    VLookup Nhiều Giá Trị  |   VLookup trên nhiều trang tính   |   Tra cứu mờ ....
Danh sách thả xuống nâng cao: Tạo nhanh danh sách thả xuống   |  Danh sách thả xuống phụ thuộc   |  Danh sách thả xuống nhiều lựa chọn ....
Trình quản lý cột: Thêm một số cột cụ thể     Di chuyển cột   |   Bỏ ẩn cột   |   So sánh các cột với Chọn các ô giống nhau và khác nhau hữu ích. Cảm ơn !
Các tính năng nổi bật: Tiêu điểm lưới   |  Chế độ xem thiết kế   |   Thanh công thức lớn    Trình quản lý sổ làm việc & trang tính   |  Thư viện tài nguyên (Văn bản tự động)   |  Bảng chọn ngày   |  Kết hợp các bảng tính   |  Mã hóa/Giải mã ô    Gửi email theo danh sách   |  Siêu lọc   |   Bộ lọc đặc biệt (lọc in đậm/nghiêng/gạch ngang...) ...
15 bộ công cụ hàng đầu12 bản văn CÔNG CỤ (thêm văn bản, Xóa ký tự,...)   |   50 + Biểu đồ Các loại (Biểu đồ Gantt,...)   |   40+ Thực tế Công thức (Tính tuổi dựa trên ngày sinh,...)   |   19 chèn CÔNG CỤ (Chèn mã QR, Chèn ảnh từ đường dẫn,...)   |   12 Chuyển đổi CÔNG CỤ (Số tới Words, Chuyển đổi tiền tệ,...)   |   7 Hợp nhất & Tách CÔNG CỤ (Các hàng kết hợp nâng cao, Chia ô,...)   |   Nhiều hơn nữahữu ích. Cảm ơn !

Kutools for Excel tự hào có hơn 300 tính năng, đảm bảo rằng những gì bạn cần chỉ là một cú nhấp chuột...

Hỗ trợ văn phòng/Excel 2007-2021 và mới hơn, bao gồm 365 | Có sẵn trong 44 ngôn ngữ | Tận hưởng bản dùng thử miễn phí 30 ngày đầy đủ tính năng.

tab kte 201905


Office Tab Mang giao diện theo thẻ vào Office và giúp công việc của bạn dễ dàng hơn nhiều

  • Cho phép chỉnh sửa theo thẻ và đọc trong Word, Excel, PowerPoint, Publisher, Access, Visio và Project.
  • Mở và tạo nhiều tài liệu trong các tab mới của cùng một cửa sổ, thay vì trong các cửa sổ mới.
  • Tăng 50% năng suất của bạn và giảm hàng trăm cú nhấp chuột cho bạn mỗi ngày!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
jak ktoś ukrył arkusz jak w opisanym pierwszym sposobie, a nie znamy hasła to jak odkryć arkusz skoro hasło do visual basic jest w ukrytym arkuszu?
This comment was minimized by the moderator on the site
Hello, ciekawa

Sorry, at present, there is no good way for canceling the protect of the hidden sheet if you forget the password.

But, you can apply the Uhide all hidden sheets feature of Kutools for Excel to unhide all the hidden sheets without any password.
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-unhide-sheets.png
You can download Kutools for Excel and use it freely for 30 days.
Please have a try. Thank you!
This comment was minimized by the moderator on the site
This is elegant. IF the person opening the spreadsheet does not enable macros (i.e. VBA) what happens? Is the hidden sheet a sitting duck? Or is it quite impossible to find?
This comment was minimized by the moderator on the site
Hi, David,
If you open the workbook without enabling the macro, the hidden sheet is displayed as normal. In this case, I recommend you to apply the first method for solving this job.
Thank you!
This comment was minimized by the moderator on the site
Your code allows users to view the sheet as long as they hold the left mouse button while the mouse pointer is on the tab. Try this to keep sheet hidden until correct password is entered: If response = "123456" Then Application.Sheets(xSheetName).Visible = True Application.Sheets(xSheetName).Select Else Application.Sheets(xSheetName).Visible = False[/b][/b] End If End If Application.EnableEvents = True End Sub
This comment was minimized by the moderator on the site
I have a question about your password restricted worksheet code. You posted the following code which works....what I am looking for is code that will do this with multiple worksheets and multiple passwords within the same workbook. Is this possible? Private Sub Workbook_SheetActivate(ByVal Sh As Object) 'Update 20140925 Dim xSheetName As String xSheetName = "sheet1" If Application.ActiveSheet.Name = xSheetName Then Application.EnableEvents = False Application.ActiveSheet.Visible = False xTitleId = "KutoolsforExcel" 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
This comment was minimized by the moderator on the site
Found a solution yet?

I am having the same problem
This comment was minimized by the moderator on the site
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim aSheetName As String
Dim bSheetName As String
Dim cSheetName As String
aSheetName = "sheet1"
bSheetName = "sheet2"
cSheetName = "sheet3"

If Application.ActiveSheet.Name = aSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "123" Then
Application.Sheets(aSheetName).Visible = True
Application.Sheets(aSheetName).Select
Else
Application.Sheets(aSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = bSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "456" Then
Application.Sheets(bSheetName).Visible = True
Application.Sheets(bSheetName).Select
Else
Application.Sheets(bSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = cSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "789" Then
Application.Sheets(cSheetName).Visible = True
Application.Sheets(cSheetName).Select
Else
Application.Sheets(cSheetName).Visible = False
End If
End If
Application.EnableEvents = True

End Sub
This comment was minimized by the moderator on the site
Thanks for the code, just have one question. When you open the sheet you are asked for question, then you enter it and the sheet is visible, but when you jump to next sheet and try to re-open previous sheet, you are asked for the same password again everytime. My question is can you bypass that and make excel ask for password once?
This comment was minimized by the moderator on the site
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim xSheetName As String
aSheetName = "sheet1"
bSheetName = "sheet2"
cSheetName = "sheet3"

If Application.ActiveSheet.Name = aSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "1234" Then
Application.Sheets(aSheetName).Visible = True
Application.Sheets(aSheetName).Select
Else
Application.Sheets(aSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = bSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "2345" Then
Application.Sheets(bSheetName).Visible = True
Application.Sheets(bSheetName).Select
Else
Application.Sheets(bSheetName).Visible = False
End If
End If
Application.EnableEvents = True

If Application.ActiveSheet.Name = cSheetName Then
Application.EnableEvents = False
Application.ActiveSheet.Visible = False
xTitleId = "KutoolsforExcel"
response = Application.InputBox("Password", xTitleId, "", Type:=2)
If response = "3456" Then
Application.Sheets(cSheetName).Visible = True
Application.Sheets(cSheetName).Select
Else
Application.Sheets(cSheetName).Visible = False
End If
End If
Application.EnableEvents = True

End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations