+ Reply to Thread
Results 1 to 5 of 5

Vba to protect the cell

Hybrid View

  1. #1
    Registered User
    Join Date
    11-27-2008
    Location
    Noida
    Posts
    51

    Re: Vba to protect the cell

    Quote Originally Posted by royUK View Post
    The default for cells is locked, so first unlock all the cells.

    Click the empty grey box between the colmn & row headers to select all cells -> Format -> Protection -> uncheck Locked. Then use this code

    Option Explicit
    
    Sub Button1_Click()
        Const PW   As String = "secret"
        Dim rNonBlanks As Range
        On Error Resume Next
        Set rNonBlanks = ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants)
        On Error GoTo 0
        rNonBlanks.Locked = True
        ActiveSheet.Protect PW
    End Sub
    Thank for reply Roy is that possible we can define the range in code so that macro will run on that range only instead on whole sheet

  2. #2
    Registered User
    Join Date
    11-27-2008
    Location
    Noida
    Posts
    51

    Re: Vba to protect the cell

    please suggest

+ 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