- Mar 26, 2020
- Office Version
Hello guys, I am able to hide and unhide the sheets when I run the code. The sheet (Original) I am supposed to enter a new data every time, to generate XML is protected and only the columns (A:J) where I am supposed to paste the data are unlocked. I have already unlocked the cells of those rows and protected the rest of the columns with a password. I have no idea why are the unprotected cells getting locked when I run the macro. I need your expert help to find the solution to solve this problem.
Option Explicit Sub HideSheets() Dim ws As Worksheet ThisWorkbook.Unprotect Password:=123 For Each ws In ThisWorkbook.Worksheets If ws.Name <> "Original" Then ws.Protect Password:=123 ws.Visible = xlSheetVeryHidden End If Next ws ThisWorkbook.Protect Password:=123 End Sub Sub UnHideSheets() Dim ws As Worksheet ThisWorkbook.Unprotect Password:=123 For Each ws In ThisWorkbook.Worksheets If ws.Name <> "Original" Then ws.Visible = xlSheetVisible End If Next ws End Sub