Run-time error '1004': Unable to set the hidden property of the range class

lovekush

New Member
Joined
May 10, 2017
Messages
4
I have this code but this show an error-Run-time error '1004': Unable to set the hidden property of the range class
And one thing more i want to use same code on different sheets in same Workbook.
Sub Hide_Unhide()
'
' Hide_Unhide Macro
' Macro recorded 5/9/2017
'
' Keyboard Shortcut: Ctrl+s
'
If Range("T3069").Value = 30 Then
Rows("3070:3121").EntireRow.Hidden = True
Else
Rows("3070:3121").EntireRow.Hidden = False
End If
End Sub


Lovekush
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
You could get that error if the worksheet is protected. If yes, try something like this. Change the password to suit.

Code:
[color=darkblue]Sub[/color] Hide_Unhide()
[color=green]'[/color]
[color=green]' Hide_Unhide Macro[/color]
[color=green]' Macro recorded 5/9/2017[/color]
[color=green]'[/color]
[color=green]' Keyboard Shortcut: Ctrl+s[/color]
[color=green]'[/color]
[B]ActiveSheet.Unprotect Password:="[COLOR=#ff0000]Secret[/COLOR]"[/B]
[color=darkblue]If[/color] Range("T3069").Value = 30 [color=darkblue]Then[/color]
Rows("3070:3121").EntireRow.Hidden = [color=darkblue]True[/color]
[color=darkblue]Else[/color]
Rows("3070:3121").EntireRow.Hidden = [color=darkblue]False[/color]
[color=darkblue]End[/color] [color=darkblue]If[/color]
[B]ActiveSheet.Protect Password:="[COLOR=#ff0000]Secret[/COLOR]"[/B]
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 
Upvote 0
Do you manually change the value in T3069 or is it a formula? If it is a formula, what is the formula?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top