+ Reply to Thread
Results 1 to 6 of 6

How to lock a cell without protecting the worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    04-27-2013
    Location
    St. Louis MO area
    MS-Off Ver
    Excel 2010
    Posts
    2

    How to lock a cell without protecting the worksheet

    I have column B with this formula =IF(C4,WEEKDAY(C4),"") where the reference value goes from C4 to C999
    This formula works great to pick the day-of-week

    I want to prohibit the user from entering TUESDAY and thus wiping-out my formula

    I have several macro's on the sheet / workbook
    I have not had any luck in unprotecting-protecting the sheet/workbook within a macro
    I guess I've spent 4 hours trying code from this, and other, forums.

    So I'm wondering if I can use DATA VALIDATION to do the job?
    There is an "in list" function ... is there a way to modify it to be "not in list" ??
    -OR-
    can I use custom-formula to somehow require what they enter to begin with "=IF(" ??

    Thanks
    Puzzled-in-St. Louis

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: How to lock a cell without protecting the worksheet

    I have developed a few forms with this functionality, so it's totally possible.

    In one form, I have a up/down arrow object that allows users to change the year for the annual employee review form, which unlocks the sheet, changes the date, relocks the sheet.

    Private Sub SpinButton1_SpinDown()
        ActiveSheet.Unprotect "prettypinkponies"
        With Range("b1")
            .Value = WorksheetFunction.Max(1900, .Value - 1)
        End With
        ActiveSheet.Protect "prettypinkponies"
    
    End Sub
    and

    Private Sub SpinButton1_SpinUp()
        ActiveSheet.Unprotect "prettypinkponies"
        With Range("b1")
            .Value = WorksheetFunction.Min(2999, .Value + 1)
        End With
        ActiveSheet.Protect "prettypinkponies"
    End Sub


    Your variation could be something as simple as:

    Private Sub Button1_Click()
        ActiveSheet.Unprotect "slightlylessweirdpassword"
        With Range("something")
            formulasomethingsomething
        End With
        ActiveSheet.Protect "slightlylessweirdpassword"
    
    End Sub

  3. #3
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: How to lock a cell without protecting the worksheet

    I guess there must be a good reason but why are you " unprotecting-protecting the sheet/workbook within a macro".

    You can do it in a macro or manually and from what you have described this seems to be what you want.


    click on the * Add Reputation if this was useful or entertaining.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: How to lock a cell without protecting the worksheet

    Another idea:

    You could select C4:C999, choose Data Validation, Text Length, minimum 22, max 26.

    Your formula string would have a min of 22 min characters long, and a max of 26 with the row reference for 999.

    The only way they could mess it up is typing something silly like MondayMondayMonday (24 characters long)

  5. #5
    Registered User
    Join Date
    04-27-2013
    Location
    St. Louis MO area
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How to lock a cell without protecting the worksheet

    Excellent and elegantly simple solution without having to mess with macro.

  6. #6
    Forum Contributor
    Join Date
    08-14-2013
    Location
    Florida
    MS-Off Ver
    Excel 2013
    Posts
    105

    Re: How to lock a cell without protecting the worksheet

    You could setup Worksheet_Change(ByVal Target As Range) to call a sub that adds your formula to the column that you need it to be in. This way if he or she enters als;kjf;lak in the cell, and hits enter... it changes things back to your formula.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How To Lock Cells and Columns without Protecting Worksheet
    By lostinformulas in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-13-2006, 06:00 PM
  2. [SOLVED] How do I lock the Column without Protecting the Sheet
    By sgmoorthy in forum Excel General
    Replies: 2
    Last Post: 11-04-2005, 10:10 AM
  3. Lock cells without protecting sheet?
    By Bernie Deitrick in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 07:05 AM

Tags for this Thread

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