Hi, I fixed the macro to read, but modifying it gives me an error here.
Sub HideUnhide12121212()
Dim WS_Count As Integer
Dim I As Integer
Application.ScreenUpdating = False
If Range("4:4").EntireRow.Hidden = False Then 'Sub hide
WS_Count = ActiveWorkbook.Worksheets.Count
For I = 1 To WS_Count
Rows("2:2").Select
Selection.Locked = False '->>> now here gives me error
Selection.FormulaHidden = False
Range( _
"4:4,5:5,10:10,11:11,13:13,14:14,17:17,18:18,34:34,35:35,38:38,45:45,46:46,49:49,50:50,72:72,73:73,76:76,77:77,78:78,79:79" _
).Select
Range("A79").Activate
Selection.EntireRow.Hidden = True
Range("A3").Select
ActiveSheet.Protect ("kosta"), DrawingObjects:=True, Contents:=True, Scenarios:=True _ ' and here at least the logic of my macro remains to lock the only the active sheet, and other .....?
, AllowFiltering:=True
Next I
Application.ScreenUpdating = True
Else 'Sub Unhide
On Error GoTo ErrHandler
ActiveSheet.Unprotect Password:=InputBox("Please write your password!")
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For I = 1 To WS_Count
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1").Select
Next I
Exit Sub
ErrHandler:
MsgBox "Wrong password", vbExclamation
'ActiveSheet.Unprotect ("kosta")
Application.ScreenUpdating = True
End If
End Sub
There is still something not clear to me.
And it is this - how and where to write just for the sheets to hide, lock and then again just the same to have the opposite effect.
I will once again give you an example, hoping to be understood:
I have for example 10 sheets:
1 - bananas
2 - london
3 - strawberries
4 - Paris
5 - Italy
6 - New Zealand
7 - Japan
8 - mushrooms
9 - Greece
10 - England
I want the macro action with a button to perform only sheets (London, Paris, Italy, New Zealand, Japan, Greece, England) and does nothing on the other (Bananas, Strawberries, mushrooms)
In your example, processing the macro - turns out that it absolutely counts all sheets, which leads me to the conclusion that all the sheets(rows) will be hidden, locked, etc.
Wrong somewhere?
Thanks for the effort, I think we left a little to finish it.