+ Reply to Thread
Results 1 to 8 of 8

Error: Cannot change the part of merged cell - When trying to lock cells in range

  1. #1
    Registered User
    Join Date
    02-16-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    78

    Error: Cannot change the part of merged cell - When trying to lock cells in range

    Hi,

    I have some ranges defined in the worksheet.

    I want to make ready only certain cells in the sheet.

    Below is code which I am using, However it is locking all the cells in the range. I want to lock the cells upto some specific row in the range.
    like till first 20 rows in the range.


    Please Login or Register  to view this content.
    I get an error message saying "Unable to set locked property of the Range Class. When I come out of debug mode it says "Cannot change the part of merged cell " , Actually the column cell is a merge of two cells...and it is bcoz of this it throwing the above error.

    Can somebody tell how to set the locked property of some cells in the range where the column cell is merged cell.

    Thanks

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error: Cannot change the part of merged cell - When trying to lock cells in range

    You can't. All cells in a merged cell are locked or not.

    This is one of about 100 reasons not to merge cells.
    Entia non sunt multiplicanda sine necessitate

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

    Re: Error: Cannot change the part of merged cell - When trying to lock cells in range

    Hi

    merging cells can lead to all kinds of trouble. If it's for cosmetic reasons, to center text across several columns, you don't need to merge the cells. Instead, just put the text in the leftmost cell, select it and the cells to the right and then go Format - Cells - Alignment tab: horizontal - center across selection (last option in the drop-down list).

    Looks exactly the same as a merged cell but can save you heaps of trouble.

    HTH

  4. #4
    Registered User
    Join Date
    02-16-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Error: Cannot change the part of merged cell - When trying to lock cells in range

    I can have the merged cells (in my case two cells merged form one column)to be locked together or unlocked together.

    I just want to lock only some 20 rows in the range where the actually range covers more than 20 rows

    the range refers to something like 'Information'!$D$10:$E$100

    Where 'Information' is the sheet name and rows start from 10 to 100 and columns are both D & E merged together as one column.

    Now, I just want to lock rows from 10 to 30 where merged column together can be locked.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Error: Cannot change the part of merged cell - When trying to lock cells in range

    Hello Ranjani,

    I modified your code to work with the merged cells. It will now lock the rows from the first row or "r" to the twentieth row of "r" on the active sheet.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Registered User
    Join Date
    02-16-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Error: Cannot change the part of merged cell - When trying to lock cells in range

    Hi Ross,

    Yes, I did try the same code you modified. However now it has locked the whole sheet.

    I am wondering , if i have missed something.

    Please Login or Register  to view this content.
    Thanks

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Error: Cannot change the part of merged cell - When trying to lock cells in range

    Hello Ranjani,

    If you post your workbook, I will review the code and fix the problem.

  8. #8
    Registered User
    Join Date
    02-16-2009
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    78

    Re: Error: Cannot change the part of merged cell - When trying to lock cells in range

    Hi,

    I have attached the file testlocked.xls file,

    and I have written the function on Workbook open event to lock the cells.

    Thanks
    Attached Files Attached Files
    Last edited by Ranjani; 03-09-2009 at 06:41 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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