+ Reply to Thread
Results 1 to 3 of 3

Insert & Delete Buttons - Protected Worksheet

  1. #1
    Registered User
    Join Date
    04-25-2012
    Location
    Central Jersey
    MS-Off Ver
    Excel 2013
    Posts
    16

    Insert & Delete Buttons - Protected Worksheet

    Attached is an example of what I would like to do.

    I have added an "Insert Row" and "Delete Row" button with code for both of them.

    The spreadsheet as it is now would be the template for a user to start adding data. Rows 5 & 6 (2 rows) are to always be present in the table.

    I would like to add the following functionality to the code for the two buttons:

    Insert Row:
    1. When a user activates this button, the code checks to see where the active row is currently. If it is at row (value of A1) through row (value of B1), the program will copy the hidden row (row 4) and insert it directly above the active row. The program will index the integer in cell B1 by 1. If active row is not within values above button does nothing.

    Delete Row:
    1. When a user activates this button, the code checks to see where the active row is currently. It does the following checks:
    a. If value of B1 is equal to A1, it does nothing.
    b. If B2 is greater than A1, and the active row (value) is between A1+1 and B1 it deletes the active row. The program then decreases the value in cell B1 by 1.

    I'm all ears for a better method to my approach if there is one.
    Attached Files Attached Files
    Last edited by cjwescott; 03-07-2013 at 11:41 PM.

  2. #2
    Registered User
    Join Date
    04-25-2012
    Location
    Central Jersey
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Insert & Delete Buttons - Protected Worksheet

    Well I managed to get some of it working. I need help with a few things.

    1. I would like to activate the cell which was active prior to executing the "Insert Row" button at the end of the code . Currently the hidden cell is active upon exit of the code.

    2. I would like to check if multiple rows are selected when the "Delete Row" button is activated. If there are I want to prevent the deletion and activate a message box.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    04-25-2012
    Location
    Central Jersey
    MS-Off Ver
    Excel 2013
    Posts
    16

    Re: Insert & Delete Buttons - Protected Worksheet

    O.k., I think I have it working the way I want. Amazing what searching the web for content will do.

    A critique of the code for areas of improvement would be well appreciated if anyone can find the time.
    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