Unable to Unhide Columns

reyrey

New Member
Joined
Jun 30, 2011
Messages
49
Hello all!

Im getting the following error below

"Unable to set the Hidden property of the Range class"

Any idea why im getting error?

Code:
Sub UnlockSheet()

Dim password As Variant
              password = Application.InputBox("Enter Password", "Password Protected")
    Select Case password
                  Case Is = False
                      
                  Case Is = "MyPassword"
                                                     
                  Case Else
                      MsgBox "Incorrect Password"
    End Select

Columns.EntireColumn.Hidden = False

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I suspect it's because, you haven't unlocked the sheet.
 
Upvote 0
To unlock the sheet try
Code:
Sub UnlockSheet()
   
   Dim PassWrd As Variant
   
   PassWrd = Application.InputBox("Enter Password", "Password Protected")
   If PassWrd = "MyPassword" Then
      Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Unprotect PassWrd
      Sheets("[COLOR=#ff0000]Sheet1[/COLOR]").Columns.EntireColumn.Hidden = False
   Else
      MsgBox "Incorrect Password"
   End If
   
End Sub
Change sheet name in red to suit
 
Upvote 0

Forum statistics

Threads
1,214,866
Messages
6,121,996
Members
449,060
Latest member
mtsheetz

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