Protected Worksheet Macro To Insert Rows?

  • Hi, I have a protected worksheet, which I have 2 macros, 1 to spell check and 1 to insert rows, they both unprotect the sheet and re protect it again once they have completed. The problem I am having is that when I protect the work sheet first time round I tick the box to allow users to insert rows, once the Macros run they disable this functionality. Is there anyway I can include this in my Macros or do I need to add a new button!


    All help appreciated.


    Thanks


    Nick

  • Re: Protected Worksheet Macro To Insert Rows?


    Look at Protection with UserInterFaceOnly, this allows changes to be made with VBA

  • Re: Protected Worksheet Macro To Insert Rows?


    Nick, below is the macro for Unprotect/Protecting a worksheet, the first line protects with password and enables insert rows, the second unprotects using password and the third protects using password but disables insert rows!

    Code
    ActiveSheet.Protect Password:="1234", AllowInsertingRows:=True
        ActiveSheet.Unprotect Password:="1234"
        ActiveSheet.Protect Password:="1234", AllowInsertingRows:=False


    Hope this helps,
    Regards,
    Simon

  • Re: Protected Worksheet Macro To Insert Rows?


    Thanks guys for your quick response....


    It was deleting rows I needed but just changed the VBA code to delete instead of insert.


    Once again, thanks.


    Nick

  • Inserting Rows Macro, Protection.


    Hi I am using the following macro to insert rows into a protected spreadsheet. It all works fine unless the user hits cancel on the popup of how many rows they want to insert, I have tried various combinations but can't get it to protect the spread sheet after they cancel or if it does it then doesn't protect it when they do insert rows....



  • Re: Inserting Rows Macro, Protection.


    Move the unprotect command to after the if statement


    Or replace

    Code
    If vRows = False Then Exit Sub


    with

    Code
    If vRows = False Then
       ActiveSheet.Protect Password:="password", AllowDeletingRows:=True, DrawingObjects:=True, _
        Contents:=True, Scenarios:=True
        Exit Sub
    End If


    Add code to change sheets if required befor protecting

  • Re: Protected Worksheet Macro To Insert Rows?


    Thanks for that, it is all working fine now, however, I would like to be able to let people change font sizes, make bold etc.....is there anyway that I can allow this on a protedcted sheet.


    Nick

  • Re: Protected Worksheet Macro To Insert Rows?


    Code
    ActiveSheet.Protect Password:="password", AllowDeletingRows:=True, DrawingObjects:=True, _
        Contents:=True, Scenarios:=True, AllowFormattingCells:=True
  • Re: Protected Worksheet Macro To Insert Rows?


    Hi, I am having some more issues now....


    It seems if a cell has more than 255 characters in it, it just displays ##### I have tried to expand it but it always shows #####. I have looked through the macros and cant see anything that would cause this.



    Anyone got any ideas, please.


    Nick

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!