+ Reply to Thread
Results 1 to 5 of 5

VBA Code/Macro to insert rows into a protected sheet and copy formulas down

  1. #1
    Registered User
    Join Date
    07-13-2017
    Location
    Newcastle, UK
    MS-Off Ver
    2010
    Posts
    10

    Red face VBA Code/Macro to insert rows into a protected sheet and copy formulas down

    Hi,

    I am very new to VBA and Macros and to be honest new to all the extended functionality in Excel. What I am trying to achieve

    I have created a table in excel and the first column is based on a drop down list in a separate sheet. There are approximately 8 items in the list and each one has adjacent cells that has data I want to copy through to the main table and auto fill certain fields.

    I have successfully managed to do the first step using Vlookup.

    I also want to protect my worksheet to stop people changing the formulas and values in the auto filled cells on the main table and allow people to add additional rows, select from the drop down in column A and auto fill the cells when the work book is protected. This is the part I am now stuck with.

    Does any one have any examples how to achieve this using VBA/Macro.

    Ideally what I would like is the following:

    - Add a button on the sheet that allows me to insert a new row in the protected sheet ideally where the cursor is on the sheet
    - Ensure the formula and drop down list is copied into the new row from the above rows
    - Select an item from the drop down list and depending on the contents auto fill the adjacent cells.

    I have attached what I have done so far if this helps.

    Hope someone can help. I am also new to the VBA editor as well so some explanation might be required as well
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: VBA Code/Macro to insert rows into a protected sheet and copy formulas down

    I was lucky enough to be given help on a similar query some time ago and have managed to adapt the code I was given to work on your data.

    Create a new macro from the developer ribbon and copy this into the window:

    Please Login or Register  to view this content.
    Now close the VBA window and run the macro on your protected sheet - a new row should be added at the bottom of the table. You can now assign this macro to a command button on your worksheet.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-13-2017
    Location
    Newcastle, UK
    MS-Off Ver
    2010
    Posts
    10

    Re: VBA Code/Macro to insert rows into a protected sheet and copy formulas down

    Hello and sorry for being cheeky but could you show me how to modify the code so it will delete a row as well

    Really Appreciate your help

    Thanks Graham

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: VBA Code/Macro to insert rows into a protected sheet and copy formulas down

    Thanks for the rep. If you need any help adapting it, you'll need one of the VBA experts, but if that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

    EDIT: just seen your second query. Hang on - I think I've got that, too!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,426

    Re: VBA Code/Macro to insert rows into a protected sheet and copy formulas down

    Try this:

    Please Login or Register  to view this content.
    If you run into any trouble, you'll need a VBA expert!

+ 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. Replies: 2
    Last Post: 06-28-2017, 04:31 PM
  2. VB Code or macro to insert 32 new rows with data and formulas
    By kmham in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-04-2015, 10:29 AM
  3. Macro to copy and insert down several rows in protected sheet
    By Sardokar21 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-28-2015, 03:15 AM
  4. Insert Row on Protected Sheet and Auto Copy Formulas
    By ltradey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-17-2014, 05:46 AM
  5. Macro to insert rows in multiple sheets and copy formulas
    By syt0x in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-25-2013, 11:06 AM
  6. Copy and paste insert rows with protected cells in protected worksheet
    By excel_gecko in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-24-2012, 05:50 PM
  7. [SOLVED] Code to cut and paste rows (insert cut cells) in a protected Excel sheet
    By bob.mc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2012, 04:47 PM

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