Advertisement
YasserKhalil2019

T3834_Enable Disable Worksheets Protection

Aug 31st, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. https://excel-egy.com/forum/t3834
  2. ---------------------------------
  3.  
  4. Sub Test_EnableDisableProtection()
  5. Dim myLink As Variant
  6.  
  7. EnableDisableProtection False
  8. Application.AskToUpdateLinks = False
  9. For Each myLink In ActiveWorkbook.LinkSources(xlExcelLinks)
  10. ActiveWorkbook.UpdateLink Name:=myLink, Type:=xlExcelLinks
  11. Next myLink
  12. Application.AskToUpdateLinks = True
  13. EnableDisableProtection True
  14. End Sub
  15.  
  16. Sub EnableDisableProtection(b As Boolean)
  17. Dim ws As Worksheet
  18.  
  19. For Each ws In ThisWorkbook.Worksheets
  20. If b Then
  21. ws.Protect "123"
  22. Else
  23. ws.Unprotect "123"
  24. End If
  25. Next ws
  26. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement