Hi all
I'm having a problem, and after many hours searching for a solution, i desidet to ask in here.
What im looking for is a macro which does:
When i close my workbook it should password protect some specific sheets, the workbook structure and then hide some of the sheets.
I simply can't find that solution.
Hope someone in here could help me.
I found this code but i can't get it to work.
PrivateSub Workbook_BeforeClose(Cancel AsBoolean)
Dim ws As Worksheet
ForEach ws In ThisWorkbook.Worksheets
If ws.Name = "HO"Or ws.Name = "BLs"Then
If ws.Visible <> xlSheetHidden Then ws.Visible = xlSheetHidden
ws.Protect "test"
Else
ws.Protect "test"
EndIf
Next ws
ThisWorkbook.Protect "chandoo", True
ThisWorkbook.Save
EndSub
I'm having a problem, and after many hours searching for a solution, i desidet to ask in here.
What im looking for is a macro which does:
When i close my workbook it should password protect some specific sheets, the workbook structure and then hide some of the sheets.
I simply can't find that solution.
Hope someone in here could help me.
I found this code but i can't get it to work.
PrivateSub Workbook_BeforeClose(Cancel AsBoolean)
Dim ws As Worksheet
ForEach ws In ThisWorkbook.Worksheets
If ws.Name = "HO"Or ws.Name = "BLs"Then
If ws.Visible <> xlSheetHidden Then ws.Visible = xlSheetHidden
ws.Protect "test"
Else
ws.Protect "test"
EndIf
Next ws
ThisWorkbook.Protect "chandoo", True
ThisWorkbook.Save
EndSub