Results 1 to 4 of 4

Cell range protect/unprotect toggle

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile Cell range protect/unprotect toggle

    Hi Guys,

    I wanted to have a piece of code that could that would create a toggle for Lock and Unlock for a range of cells.

    The code below unprotects the sheet so that I can set the protection for the range and then re-protects the sheet.

    Is there an If and Else command to say IF range (A8:B20) is locked then unlock ELSE lock?

    The reason I need this is that I have a budget spreadsheet and I may need to change the descriptions and price values of those ranges without having the rest of the worksheet vulnerable to being unlocked.

    Can someone help me out please, below is the code I have so far I just need the blanks filled in where it says 'My Code starts here'

    Thanks in advance.

    Sub Protectsheet()
    
    Dim Rng As Range
    Set Rng = Range("A8:B20")
            Sheet1.Unprotect "Password"
         'My Code starts here
    
          'My Code ends here
                Sheet1.Protect "Password"
                Sheet1.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
            , AllowSorting:=True, AllowFiltering:=True
            wSht.EnableSelection = xlUnlockedCells
            
            
    End Sub
    Last edited by Zyphon; 02-21-2008 at 04:52 AM.
    Best Regards.

    Michael
    -----------------------------------
    Windows Vista, Microsoft Office 2007

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