+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : Lock cell if Blank formula

Hybrid View

  1. #1
    Registered User
    Join Date
    09-15-2010
    Location
    Here, Now
    MS-Off Ver
    Excel 2007
    Posts
    13

    Lock cell if Blank formula

    Is it possible to flag an unlocked/unprotected cell to locked if blank, with a formula?
    Last edited by SIXFORTYSIX; 09-29-2010 at 03:35 PM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Lock cell if Blank formula

    You can't change the lock flag with a formula. You'll need VBA.

  3. #3
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Lock cell if Blank formula

    Like below

    
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim Cell As Range
        On Error GoTo ErrHandler
        Me.Unprotect
        For Each Cell In Cells.SpecialCells(xlCellTypeFormulas)
            With Cell
                If .Value = "" Then
                    .Locked = True
                Else
                    .Locked = False
                End If
            End With
        Next Cell
        Me.Protect
        Exit Sub
    ErrHandler:
        If Err.Number > 0 Then
            Err.Clear
            Resume Next
        End If
    End Sub

    How to Save a Workbook Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on any Worksheet's Name Tab
    3. Left Click on View Code in the pop up menu.
    4. Press the Enter key to move the cursor to the Code Window
    5. Paste the macro code using CTRL+V
    6. Save the macro in your Workbook using CTRL+S
    Last edited by contaminated; 09-23-2010 at 05:53 PM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  4. #4
    Registered User
    Join Date
    09-15-2010
    Location
    Here, Now
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Lock cell if Blank formula

    I've Adapted that VBA and it works!!!! Thanks!

+ 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