Consulting

Results 1 to 2 of 2

Thread: protect a sheet

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    protect a sheet

    hello
    i want to enable a user change data on a sheet but not formulas.
    [VBA]
    Dim cell As Range
    For Each cell In ActiveSheet.UsedRange
    With ActiveSheet
    .Unprotect
    If cell.HasFormula Then
    cell.Locked = True
    Else
    cell.Locked = False
    ActiveSheet.Protect
    End If
    End With
    Next

    [/VBA]
    is it possible to do it?
    thanks
    moshe

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim cell As Range
    For Each cell In ActiveSheet.UsedRange
    With ActiveSheet
    .Unprotect
    cell.Locked = cell.HasFormula
    .Protect
    End With
    Next
    [/vba]

Posting Permissions

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