+ Reply to Thread
Results 1 to 9 of 9

lock cells for edit without using sheet protection

  1. #1
    Registered User
    Join Date
    12-07-2007
    Posts
    20

    lock cells for edit without using sheet protection

    Hi, I want to know if there's any ways I can lock certain cells in an excel sheet without using the sheet protection. The reason why I don't use the sheet protection is because when I enable it, my command button and popup calendar doesn't work. I am looking for a vba code that allow me to lock certain cells, the cells contain formula and there's no need to edit them. 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: lock cells for edit without using sheet protection

    You cannot protect cells other than by protecting the sheet. Properly implemented, sheet protection shouldn't bother command buttons or your pop-up calendar.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-07-2007
    Posts
    20

    Re: lock cells for edit without using sheet protection

    Hi, maybe you can help me out with protecting the sheet, this is the code for my command button and it sorts all the rows, maybe that's the problem?

    Please Login or Register  to view this content.
    When I debug it points to the oRange.Sort Key1:=Range("B4"), Order1:=iOrder, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Last edited by jimjaix; 03-10-2009 at 03:45 PM.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: lock cells for edit without using sheet protection

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  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: lock cells for edit without using sheet protection

    Hello jimjaix,

    You should check the value of "iOrder". It is probably zero. You declare it a Static Integer, but don't assign it an initial value. When tested in the If...Then, there it never changes because it is zero and doesn't match either of the Excel sorting constants.
    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
    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: lock cells for edit without using sheet protection

    You code looks fine. iOrder will be set to xlAscending in the first iteration and toggle thereafter.

    At the beginning of the code, add this line:

    Please Login or Register  to view this content.
    BTW, what is the error message you get?

  7. #7
    Registered User
    Join Date
    12-07-2007
    Posts
    20

    Re: lock cells for edit without using sheet protection

    Tried that code it didn't work, the error message I am getting once I protect the sheet and use the sort button is "Run-Time error '1004', The cell or chart you are trying to change is protected and therefore read-only. To modify a protected cell or chart, first remove the protection using the unprotect sheet command. you may be promoted for a password."


    Quote Originally Posted by shg View Post
    You code looks fine. iOrder will be set to xlAscending in the first iteration and toggle thereafter.

    At the beginning of the code, add this line:

    Please Login or Register  to view this content.
    BTW, what is the error message you get?

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: lock cells for edit without using sheet protection

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  9. #9
    Registered User
    Join Date
    12-07-2007
    Posts
    20

    Re: lock cells for edit without using sheet protection

    I attached the file. Hope this will help...


    Quote Originally Posted by royUK View Post
    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Attached Files Attached Files

+ 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