+ Reply to Thread
Results 1 to 8 of 8

Delete rows in a protected sheet with protected cells

  1. #1
    Registered User
    Join Date
    10-20-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    8

    Delete rows in a protected sheet with protected cells

    Hi,

    I want to allow users to delete rows from a protected worksheet.
    The rows contains locked cells, and therefor this causes problems.

    Is there a "work-around" to solve this problem?

  2. #2
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    16,421

    Re: Delete rows in a protected sheet with protected cells

    The first issue may be a design problem. There is a contradiction in locking cells vs. allowing users to delete the rows. Why are they locked if you want to allow deletion?

    Anyway, the workaround is to write a macro that unprotects the sheet, deletes the row, then re-protects the sheet. This is for protection without a password.

    Please Login or Register  to view this content.
    If locked with a password then you have to explicitly put the password in the code. Then if you want to hide the code you have to password-protect it.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-20-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Delete rows in a protected sheet with protected cells

    Hi,

    Regarding the design problem, is it not a "problem".
    The users tend to delete formulars, eventhoug they are told not to, but since its a tool for them to work in, they should be allowed to delete rows.

    If i put in the macro, how does I make it run automaticly when they are trying to delete the row - is there a call, or do I have to overwrite the commando ctrl + "-"?

    Thanks

  4. #4
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    16,421

    Re: Delete rows in a protected sheet with protected cells

    Needing to do something that Excel was designed to prevent sounds like a problem to me.

    CTRL + - deletes the contents of cells if the entire row is selected, which isn't what you want. If you do not have a row selected, CTRL + - brings up a dialog which asks what you're trying to delete, which may still not be what you want. In any case, to assign a hotkey to a macro you have to use a letter, so you can't override CTRL + -.

    The way I would do this is to provide a Delete Row button on the worksheet that executes the DeleteSelectedRow Sub. Or you could select a letter. Letters that Excel does not already use are E, J, M, Q, although you could reassign one already in use.

  5. #5
    Registered User
    Join Date
    10-20-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Delete rows in a protected sheet with protected cells

    Sounds like a good solution with the button.

    Thanks.

  6. #6
    Registered User
    Join Date
    10-20-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Delete rows in a protected sheet with protected cells

    The code worked fine.

    What if I want to cut or copy a row in one protected sheet and paste or insert the cuted cells in another protected sheet. Is that possible?

    Thanks again.

  7. #7
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    16,421

    Re: Delete rows in a protected sheet with protected cells

    It's possible, but you similarly have to unprotect and reprotect the destination sheet to do the paste. The code isn't hard--the "interesting" part is designing how this process should work from the user's point of view.

  8. #8
    Registered User
    Join Date
    10-20-2011
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Delete rows in a protected sheet with protected cells

    Hi,

    The solution will be the same as the other one.
    I am planning to create some buttons when this is needed.

+ 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