+ Reply to Thread
Results 1 to 8 of 8

Lock cells with text only

  1. #1
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Lock cells with text only

    Hi, I need to lock the cells in my sheets with text only and allowing the blanks one to be edited.

    I found this following code. However, it locks all the blank cells as well.

    Can anyone advise?

    Also, I need another similar macro to lock cells with text only across multiple sheets at one shot. Appreciate if anyone is willing to help.

    Thank you!


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Lock cells with text only

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Lock cells with text only

    Hi stnkynts,

    Thank you for your reply.

    I tried and this code works perfectly. However, there is a catch. I have to select all the cells first, then format cells >> protection >> uncheck locked.
    It will only work after doing these.

    Is it possible to add these steps into the code?

    Also, if i would like run this code across multiple sheets, would be adding a select all sheets code works?

    Thank you very much!

  4. #4
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Lock cells with text only

    Hello,

    The default for the cells is locked. This code will go through every single sheet and lock the specified range. See if this code helps you out:

    Please Login or Register  to view this content.
    and a less heavily commented version:
    Please Login or Register  to view this content.
    Thanks

  5. #5
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Lock cells with text only

    My apologies.

    I thought asking a general question can solve my problem.

    The code was working well when I test it. However, if I tested them on my actual report, it will show error message.

    Attached is my actual work. I have 30 sheets but I just included 2 only.

    Appreciate any assistance.

    Thank you.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Lock cells with text only

    fredlo2010 code works just fine on the sample you provided. You're doing something wrong.

    Note: You can edit fredlo2010 code so that it automatically unprotects the sheets without having to enter a password just by editing the .Unprotect line to include a password in the same manner as the .Protect line
    Last edited by stnkynts; 12-12-2013 at 11:27 AM.

  7. #7
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Lock cells with text only

    Quote Originally Posted by stnkynts View Post
    fredlo2010 code works just fine on the sample you provided. You're doing something wrong.
    Note: You can edit fredlo2010 code so that it automatically unprotects the sheets without having to enter a password
    Thanks for the catch stnkynts

    This is how the final code would look:

    Please Login or Register  to view this content.
    Thanks

  8. #8
    Forum Contributor
    Join Date
    11-21-2013
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    168

    Re: Lock cells with text only

    Thank you very much stnkynts and fredlo2010.

    I think it was due to something wrong with my file. I resave it and it works flawlessly now.

    Thank you!

    Regards,
    HC

+ 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. Replies: 5
    Last Post: 07-15-2013, 03:57 AM
  2. Lock Range of Cells After Text is Entered
    By cshenold in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2012, 01:21 PM
  3. Replies: 2
    Last Post: 02-22-2012, 10:10 AM
  4. Lock cells from entering text when value is met
    By Propnistasaga in forum Excel General
    Replies: 0
    Last Post: 06-14-2010, 08:08 AM
  5. Can I lock cells or do I have to lock the worksheet?
    By jmbtexas in forum Excel General
    Replies: 4
    Last Post: 11-11-2008, 02:26 PM

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