+ Reply to Thread
Results 1 to 2 of 2

VBA Hide/Unhide Rows when Sheet protected

  1. #1
    Registered User
    Join Date
    05-04-2011
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    35

    VBA Hide/Unhide Rows when Sheet protected

    I get error with thise code end with:

    "
    Sub BACKGROUND_Click()
    Const MyPassword As String = "password"
    Dim ChangeProtection As Boolean

    With Sheets("Sheet1")
    If .ProtectContents = True Then
    .Unprotect (MyPassword)
    ChangeProtection = True
    End If

    If Rows("14:25").EntireRow.Hidden = False Then
    Rows("14:25").EntireRow.Hidden = True
    Else
    Rows("14:25").EntireRow.Hidden = False
    End If

    If ChangeProtection = True Then
    .Protect (MyPassword)
    End With
    End Sub
    "
    Last edited by Kinez101; 04-25-2012 at 12:00 PM.

  2. #2
    Registered User
    Join Date
    05-04-2011
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: VBA Hide/Unhide Rows when Sheet protected

    Here is the solution to this:

    "Sub BACKGROUND_Click()
    Const MyPassword As String = "password"
    Dim ChangeProtection As Boolean

    With Sheets("Form W-9")
    If .ProtectContents = True Then
    .Unprotect (MyPassword)
    ChangeProtection = True
    End If

    If Rows("14:25").EntireRow.Hidden = False Then
    Rows("14:25").EntireRow.Hidden = True
    Else
    Rows("14:25").EntireRow.Hidden = False
    End If

    If ChangeProtection = True Then
    .Protect (MyPassword)
    End If
    End With
    End Sub"

+ 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