Hola Elsa, mil gracias por la respuesta, funciona perfecto. tengo una duda: necesito que la rutina desbloquee la hoja, después de la boquee, incluí la rutina pero no me funciona, que estoy haciendo mal?
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect Password:="XXXX"
If Target.Address <> "$D$1" Then Exit Sub
Select Case Target.Value
Case 2015
Call Ano_1
Case 2016
Call Ano_2
Case 2017
Call Ano_3
End Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering _
:=True, Password:="XXXX"
End Sub
Sub Ano_1()
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="XXXX"
Columns("AJ:AN").Select
Selection.EntireColumn.Hidden = False
Columns("AO:AX").Select
Selection.EntireColumn.Hidden = True
Range("AC4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering _
:=True, Password:="XXXX"
Application.ScreenUpdating = True
End Sub
Sub Ano_2()
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="XXXX"
Columns("AJ:AN").Select
Selection.EntireColumn.Hidden = True
Columns("AO:AS").Select
Selection.EntireColumn.Hidden = False
Columns("AT:AX").Select
Selection.EntireColumn.Hidden = True
Range("AC4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering _
:=True, Password:="XXXX"
Application.ScreenUpdating = True
End Sub
Sub Ano_3()
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="XXXX"
Columns("AJ:AS").Select
Selection.EntireColumn.Hidden = True
Columns("AT:AX").Select
Selection.EntireColumn.Hidden = False
Range("AC4").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering _
:=True, Password:="XXXX"
Application.ScreenUpdating = True
End Sub