+ Reply to Thread
Results 1 to 2 of 2

Locking cells with macro

Hybrid View

  1. #1
    Registered User
    Join Date
    12-13-2011
    Location
    farmington MI
    MS-Off Ver
    Excel 2003
    Posts
    81

    Lightbulb Locking cells with macro

    Hi excel gurus, My requirement is to lock cells to avoid tampering as files is being accessed by many users.

    I have found below code which does the work, But If worksheet contains merged cells this script doesn't seems to be working. Could some please help fixing this issue


    -------------
    Sub Main()


    With ActiveSheet
    .Unprotect Password:="oVc0obr02WpXeZGy"
    .Cells.Locked = False
    For Each Cell In ActiveSheet.UsedRange
    If Cell.Value = "" Then
    Cell.Locked = False
    Else
    Cell.Locked = True
    End If
    Next Cell
    .Protect Password:="oVc0obr02WpXeZGy"
    End With


    End Sub
    ------------------


    Regards--Var
    Last edited by var; 06-15-2012 at 05:07 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,005

    Re: Locking cells with macro

    Please use Code Tags around your code excerpt to comply with the forum rules.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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