Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Code Problem (Excel 2002/2003)

    Hi

    On the worksheet named Agreement I have a control that Hides Rowe 63 to 66, when I leave the worksheet i would like the rows unhidden.

    But the code stops at Rows("63:66").Select. The worksheet is protected with a password.



    Private Sub Worksheet_Deactivate()
    Sheets("Agreement").Unprotect Password:="Password"

    Rows("63:66").Select
    Selection.EntireRow.Hidden = False
    Sheets("Agreement").Protect Password:="Password"

    End Sub


    Regards

    Braddy
    If you are a fool at forty, you will always be a fool

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code Problem (Excel 2002/2003)

    Replace

    Rows("63:66").Select
    Selection.EntireRow.Hidden = False

    with

    Rows("63:66").Hidden = False

    If that doesn't work, please report the error message you get.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Northampton, Northamptonshire, England
    Posts
    1,951
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Code Problem (Excel 2002/2003)

    Hi Hans

    That worked fine.

    Thanks very much.

    Braddy
    If you are a fool at forty, you will always be a fool

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code Problem (Excel 2002/2003)

    Wouldn't it be better to use:

    <code>
    Sheets("Agreement").Rows("63:66").Hidden = False
    </code>
    Legare Coleman

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Code Problem (Excel 2002/2003)

    The code runs in a worksheet event module, so Rows automatically applies to that worksheet. Braddy could also have omitted Sheets("Agreement").from the Protect and Unprotect lines.

    The problem with the original code was that Selection isn't valid any more when deactivating the sheet.

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code Problem (Excel 2002/2003)

    OK, I didn't look closely enough.
    Legare Coleman

Posting Permissions

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