+ Reply to Thread
Results 1 to 4 of 4

1004 - Unable to set the hidden property of the range class

  1. #1
    Tim Whitley
    Guest

    1004 - Unable to set the hidden property of the range class

    I'm getting the error mentioned in the subject line when I initially click
    (first open the workbook) on either of the command buttons associated with
    the code below. Once I manually unprotect the worksheet, the command buttons
    work correctly. Any help would be appreciated.

    When you click the protect button, the sheet should hide the billing
    information, protect the sheet from being edited and save the sheet. When
    you click the unprotect button, it should ask you for the password and unhide
    the information. I'm using VBA for Excel 2003.

    Thanks in advance for any help.

    Private Sub CommandButton1_Click()
    '
    ' Protect Macro
    ' Macro recorded 02/16/2006 by Tim Whitley
    '
    ' Keyboard Shortcut: Ctrl+Shift+M
    '
    Rows("33:40").Select
    Selection.EntireRow.Hidden = True

    ActiveSheet.Protect Password:="show$", Contents:=True, _
    Scenarios:=False, DrawingObjects:=True, _
    UserInterfaceOnly:=True

    ActiveWorkbook.Save

    End Sub

    Private Sub CommandButton2_Click()
    '
    ' Unlockit Macro
    ' Macro recorded 02/17/2006 by Tim Whitley
    '
    ' Keyboard Shortcut: Ctrl+Shift+O

    'must lock VBA project so you can't see the password in it
    Dim MyStr1 As String, MyStr2 As String
    MyStr2 = ("show$") 'This is the password and it is CASE sensitive
    MyStr1 = InputBox("Password Required")
    If MyStr1 = MyStr2 Then

    Rows("33:40").Select
    Selection.EntireRow.Hidden = False
    ActiveSheet.Unprotect Password:=MyStr1

    Else
    MsgBox ("Access Denied")
    End If

  2. #2
    Bob Phillips
    Guest

    Re: 1004 - Unable to set the hidden property of the range class

    Just unprotect it before hiding anything.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Tim Whitley" <[email protected]> wrote in message
    news:[email protected]...
    > I'm getting the error mentioned in the subject line when I initially click
    > (first open the workbook) on either of the command buttons associated with
    > the code below. Once I manually unprotect the worksheet, the command

    buttons
    > work correctly. Any help would be appreciated.
    >
    > When you click the protect button, the sheet should hide the billing
    > information, protect the sheet from being edited and save the sheet. When
    > you click the unprotect button, it should ask you for the password and

    unhide
    > the information. I'm using VBA for Excel 2003.
    >
    > Thanks in advance for any help.
    >
    > Private Sub CommandButton1_Click()
    > '
    > ' Protect Macro
    > ' Macro recorded 02/16/2006 by Tim Whitley
    > '
    > ' Keyboard Shortcut: Ctrl+Shift+M
    > '
    > Rows("33:40").Select
    > Selection.EntireRow.Hidden = True
    >
    > ActiveSheet.Protect Password:="show$", Contents:=True, _
    > Scenarios:=False, DrawingObjects:=True, _
    > UserInterfaceOnly:=True
    >
    > ActiveWorkbook.Save
    >
    > End Sub
    >
    > Private Sub CommandButton2_Click()
    > '
    > ' Unlockit Macro
    > ' Macro recorded 02/17/2006 by Tim Whitley
    > '
    > ' Keyboard Shortcut: Ctrl+Shift+O
    >
    > 'must lock VBA project so you can't see the password in it
    > Dim MyStr1 As String, MyStr2 As String
    > MyStr2 = ("show$") 'This is the password and it is CASE sensitive
    > MyStr1 = InputBox("Password Required")
    > If MyStr1 = MyStr2 Then
    >
    > Rows("33:40").Select
    > Selection.EntireRow.Hidden = False
    > ActiveSheet.Unprotect Password:=MyStr1
    >
    > Else
    > MsgBox ("Access Denied")
    > End If




  3. #3
    Ian
    Guest

    Re: 1004 - Unable to set the hidden property of the range class

    Try this:
    ActiveSheet.Unprotect Password:=MyStr1
    Rows("33:40").Select
    Selection.EntireRow.Hidden = False

    You need to unlock the sheet before you can unhide the rows.

    --
    Ian
    --
    "Tim Whitley" <[email protected]> wrote in message
    news:[email protected]...
    > I'm getting the error mentioned in the subject line when I initially click
    > (first open the workbook) on either of the command buttons associated with
    > the code below. Once I manually unprotect the worksheet, the command
    > buttons
    > work correctly. Any help would be appreciated.
    >
    > When you click the protect button, the sheet should hide the billing
    > information, protect the sheet from being edited and save the sheet. When
    > you click the unprotect button, it should ask you for the password and
    > unhide
    > the information. I'm using VBA for Excel 2003.
    >
    > Thanks in advance for any help.
    >
    > Private Sub CommandButton1_Click()
    > '
    > ' Protect Macro
    > ' Macro recorded 02/16/2006 by Tim Whitley
    > '
    > ' Keyboard Shortcut: Ctrl+Shift+M
    > '
    > Rows("33:40").Select
    > Selection.EntireRow.Hidden = True
    >
    > ActiveSheet.Protect Password:="show$", Contents:=True, _
    > Scenarios:=False, DrawingObjects:=True, _
    > UserInterfaceOnly:=True
    >
    > ActiveWorkbook.Save
    >
    > End Sub
    >
    > Private Sub CommandButton2_Click()
    > '
    > ' Unlockit Macro
    > ' Macro recorded 02/17/2006 by Tim Whitley
    > '
    > ' Keyboard Shortcut: Ctrl+Shift+O
    >
    > 'must lock VBA project so you can't see the password in it
    > Dim MyStr1 As String, MyStr2 As String
    > MyStr2 = ("show$") 'This is the password and it is CASE sensitive
    > MyStr1 = InputBox("Password Required")
    > If MyStr1 = MyStr2 Then
    >
    > Rows("33:40").Select
    > Selection.EntireRow.Hidden = False
    > ActiveSheet.Unprotect Password:=MyStr1
    >
    > Else
    > MsgBox ("Access Denied")
    > End If




  4. #4
    Tim Whitley
    Guest

    RE: 1004 - Unable to set the hidden property of the range class

    Thanks for your help Bob and Ian...problem solved.

    "Tim Whitley" wrote:

    > I'm getting the error mentioned in the subject line when I initially click
    > (first open the workbook) on either of the command buttons associated with
    > the code below. Once I manually unprotect the worksheet, the command buttons
    > work correctly. Any help would be appreciated.
    >
    > When you click the protect button, the sheet should hide the billing
    > information, protect the sheet from being edited and save the sheet. When
    > you click the unprotect button, it should ask you for the password and unhide
    > the information. I'm using VBA for Excel 2003.
    >
    > Thanks in advance for any help.
    >
    > Private Sub CommandButton1_Click()
    > '
    > ' Protect Macro
    > ' Macro recorded 02/16/2006 by Tim Whitley
    > '
    > ' Keyboard Shortcut: Ctrl+Shift+M
    > '
    > Rows("33:40").Select
    > Selection.EntireRow.Hidden = True
    >
    > ActiveSheet.Protect Password:="show$", Contents:=True, _
    > Scenarios:=False, DrawingObjects:=True, _
    > UserInterfaceOnly:=True
    >
    > ActiveWorkbook.Save
    >
    > End Sub
    >
    > Private Sub CommandButton2_Click()
    > '
    > ' Unlockit Macro
    > ' Macro recorded 02/17/2006 by Tim Whitley
    > '
    > ' Keyboard Shortcut: Ctrl+Shift+O
    >
    > 'must lock VBA project so you can't see the password in it
    > Dim MyStr1 As String, MyStr2 As String
    > MyStr2 = ("show$") 'This is the password and it is CASE sensitive
    > MyStr1 = InputBox("Password Required")
    > If MyStr1 = MyStr2 Then
    >
    > Rows("33:40").Select
    > Selection.EntireRow.Hidden = False
    > ActiveSheet.Unprotect Password:=MyStr1
    >
    > Else
    > MsgBox ("Access Denied")
    > End If


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1