Closed Thread
Results 1 to 8 of 8

Macro to insert new row in protected worksheet

  1. #1
    Registered User
    Join Date
    01-11-2008
    Location
    Gaillimh, Ireland
    Posts
    7

    Macro to insert new row in protected worksheet

    Hi folks,

    I need a macro that will run from a command button ('New Entry') that will insert a new row into a worksheet. The new row will need to have the following properties:

    - must be unprotected so that a user can enter data
    - must have the same formating as the previous row (i.e. keep the dropdown lists)

    I have attached an example of the excel sheet I will need the macro to run on, the protection password is 'x'.

    Total n00b to VBA so all help appreciated,

    K
    Attached Files Attached Files
    Last edited by KoemansCC; 01-17-2008 at 01:26 AM.

  2. #2
    Registered User
    Join Date
    01-11-2008
    Location
    Gaillimh, Ireland
    Posts
    7
    No need for worksheet to be protected...any tips appreciated

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Unprotect sheet insert row protect sheet again

    Quote Originally Posted by KoemansCC
    No need for worksheet to be protected...any tips appreciated
    This seems to work in my xl 2003, copies the row from above including unlocking the cells
    Please Login or Register  to view this content.

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    Hi KoemansCC,

    Try this code attached to your button called 'NewEntry':
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-11-2008
    Location
    Gaillimh, Ireland
    Posts
    7
    Thanks for the quick reply guys, both methods work very well but there are slight niggles with both methods(very slight though).

    Please Login or Register  to view this content.
    The macro works excellent but when the new lines are added the cells contain all the properties bar the borders, is there a way to alter the macro so that the borders are included each time the command button is pressed.

    Please Login or Register  to view this content.
    This macro also works excellent but when I click the command button the new line is always inserted into the second row of the table after the first row and the entries are then listed in reverse order as follows

    i.e
    1st entry
    ... (new data entered here each time)
    4th entry
    3rd entry
    2nd entry

    This may not actually be an issue as it may be a clearer method of presenting the data and the first entry could be used as an example. but is there any method to list the data in sequential order.

    i.e.
    1st entry
    2nd enty
    3rd entry
    ...(new data entered here each time)

    Thanks for the help so far, this really is an interesting forum...

    Go raibh maith agat.
    K

  6. #6
    Registered User
    Join Date
    01-11-2008
    Location
    Gaillimh, Ireland
    Posts
    7
    Please Login or Register  to view this content.
    The macro works excellent but when the new lines are added the cells contain all the properties bar the borders, is there a way to alter the macro so that the borders are included each time the command button is pressed.
    Problem solved, I just put a border on cells B7:K7 and hid row 7 from view...

  7. #7
    Registered User
    Join Date
    05-07-2015
    Location
    India
    MS-Off Ver
    MS office 2010
    Posts
    3

    Re: Macro to insert new row in protected worksheet

    Dear All,

    Can I have the coding for insertion of row after the active cell? Further I did not want to insert the entire row, I just want to add cell from A7 : O7 or A:O whereever below the active cell.

    regards
    Dharmesh

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Macro to insert new row in protected worksheet

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

Closed 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