+ Reply to Thread
Results 1 to 12 of 12

Macro to Insert row and protect som cells anywhere in the Worksheet

  1. #1
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Macro to Insert row and protect som cells anywhere in the Worksheet

    Hello,

    I need to run a macro that would insert me a row wherever the cell is active in the worksheet and to protect only from the inserted row the cells D*,F*:H*,J*,N*.

    I recorded a macro but obviously the macro does not work anywhere in the worksheet:

    HTML Code: 
    Can you please help me to figure that out?

    Thanks,
    Graig

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Do you want this to happen automatically when you select the cell or do you want to run a macro manually to do what you want? If you could post a copy of your file with a detailed explanation, it would be very helpful.

  3. #3
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    I would like to manually execute the macro.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Start by protecting your worksheet without a password. If you want to use a password, the code has to be modified to include the password. Click on any cell to make it active and then run the macro. All the cells in the inserted row will be available for data entry except for those in columns D*,F*:H*,J*,N*.
    Please Login or Register  to view this content.
    Last edited by Mumps1; 11-19-2013 at 11:13 AM. Reason: Edited code

  5. #5
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    It works well!! Many thanks. However, I forgot to say that the inserted rows need to be in a Table1.

    Is there any way to protect the entire column D, F, G, H, J, N INSIDE the Table1 ?? Otherwise when I run your macro it removes the protection I have in the table in the "column" D, F, G, H, J, N (at least it remove the protected cells from the table1).

    Thanks

  6. #6
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Byw, My worksheet has as password and the protection should allow the user to:
    Select Unlocked cells
    Format cells
    Format rows
    Insert rows
    Delete rows

    HTML Code: 
    Thanks

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Try this macro. It will protect the entire columns D, F, G, H, J, N and allow you to format the cells. I don't believe that Excel allows you to manually insert and delete rows on a protected sheet. It can only be done through VBA.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Thanks. I got the line:
    HTML Code: 
    in error

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    I tried the code on a dummy sheet and I didn't get any error. Can you post a copy of your file?

  10. #10
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Here is the sample file. I should be clearer this way :-D.

    If you do a CTRL + T. It will excecute the macro you gave me.

    Please let me know if you do not get an error.

    Thanks,
    Graig
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    02-21-2007
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    389

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Later on in that file, I will probably need to create another macro to cut and paste rows...

    So, if you know a macro to protect back in the table1 the column 3, 5, 6, 7, 9, 13 or (D28:D70;F28:H70;J28:J70;N28:N70) from the attached file I would be able to implement it in th below macro:

    HTML Code: 
    Thanks,
    Graig

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Macro to Insert row and protect som cells anywhere in the Worksheet

    Hi Graig. I still get the error. I could not see the first 11 rows of your sheet. Is it possible that you have merged cells anywhere in column J?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Insert new rows into a protect worksheet
    By CCSFM Excel2007 in forum Excel General
    Replies: 3
    Last Post: 10-14-2013, 12:34 AM
  2. Replies: 8
    Last Post: 05-21-2012, 02:25 PM
  3. Replies: 5
    Last Post: 01-20-2006, 09:25 PM
  4. How can I protect cells and allow users to insert/delete
    By Jammy Dodger in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-12-2006, 06:20 AM
  5. Protect Worksheet but allow to insert or delete rows
    By Bob L Hilliard in forum Excel General
    Replies: 2
    Last Post: 06-09-2005, 11:05 AM

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