Len tak prikladám kód ktorý by ti mohol napovedať niečo aj o Dim
'zamkne všetky listy
Public Sub ProtectGroupedSheets()
Const csPASSWD As String = "drowssap"
Dim mySheets As Sheets
Dim actSheet As Worksheet
Dim wkSht As Worksheet
Set actSheet = ActiveSheet
Set mySheets = ActiveWindow.SelectedSheets
actSheet.Select
For Each wkSht In mySheets
wkSht.Protect Password:=csPASSWD
Next wkSht
actSheet.Select
mySheets.Select False
End Sub
'odomkne všetky listy
Public Sub UnProtectGroupedSheets()
Const csPASSWD As String = "drowssap"
Dim mySheets As Sheets
Dim actSheet As Worksheet
Dim wkSht As Worksheet
Set actSheet = ActiveSheet
Set mySheets = ActiveWindow.SelectedSheets
actSheet.Select
For Each wkSht In mySheets
wkSht.Unprotect Password:=csPASSWD
Next wkSht
actSheet.Select
mySheets.Select False
End Subcitovat