+ Reply to Thread
Results 1 to 4 of 4

VB for locking and unlocking selected cell

  1. #1
    Registered User
    Join Date
    02-01-2010
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    VB for locking and unlocking selected cell

    i'm new to VB and using excel to create a simple system. The system is to track inventory hence when an authorized ID is type in the ID column all the other cell will be unlock and the staff can enter the require data into the required field. So the problem is i cant manage to find VB code on locking and unlocking selected cell in excel.

  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: VB for locking and unlocking selected cell

    Hi,

    you need to understand that you format a cell to be locked or unlocked with the Locked property. You will then need to protect the sheet with the Worksheet.Protect method.

    You'll have to alternate between protecting and unprotecting the worksheet in your code, and change individual cells' Locked property in between.

  3. #3
    Registered User
    Join Date
    02-01-2010
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: VB for locking and unlocking selected cell

    I know how to lock and protect manually on the selected cell. However, i not clear on the coding for protecting and unprotecting cell.

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

    Re: VB for locking and unlocking selected cell

    fire up the macro recorder, select a couple of cells, unlock them with the format dialog. select one or more of those cells again and lock them with the format dialog.

    Stop the macro recorder and study the code. Get rid of the Select statements and take the direct approach.

    Post your code if you get stuck.

+ 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